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: $@";
}