]> git.etc.gen.nz Git - spong.git/commitdiff
status() routine now tries upto 30 times to connect to spong-server
authorStephen L Johnson <sjohnson@monsters.org>
Thu, 10 Feb 2000 02:21:49 +0000 (02:21 +0000)
committerStephen L Johnson <sjohnson@monsters.org>
Thu, 10 Feb 2000 02:21:49 +0000 (02:21 +0000)
src/lib/Spong/Status.pm

index f0822bd5e7d2efb6624c43523bc925ba2f77a4a5..fcb5d41caea3ad7f121288ead337ba9878e5565c 100755 (executable)
@@ -28,14 +28,22 @@ sub status {
    my( $addr, $host, $cat, $color, $summary, $message ) = @_;
    my( $sock, $ok );
 
-   $sock = IO::Socket::INET->new( PeerAddr => $addr,
-                                  PeerPort => $main::SPONG_UPDATE_PORT,
-                                  Proto    => 'tcp',
-                                  Timeout  => 30,
-                                  Reuse    => 1,
-                                );
-
-   if ( ! defined $sock ) {
+   # Try 30 times to connect to spong-server
+   for ( 1..30 ) {
+      $sock = IO::Socket::INET->new( PeerAddr => $addr,
+                                     PeerPort => $main::SPONG_UPDATE_PORT,
+                                     Proto    => 'tcp',
+                                     Timeout  => 30,
+                                     Reuse    => 1,
+                                   );
+
+      if ( defined $sock ) { # Once we got a connection, exit the loop
+         last;
+      }
+      sleep 1;  # Pause a second to not overwhelm the network stack
+   }
+
+   if (! defined $sock ) {
       croak "Could not connect with Spong Server: $@";
    }