diff options
Diffstat (limited to 'lib/App/Termcast.pm')
-rw-r--r-- | lib/App/Termcast.pm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/App/Termcast.pm b/lib/App/Termcast.pm index bf719e5..1a11b07 100644 --- a/lib/App/Termcast.pm +++ b/lib/App/Termcast.pm @@ -138,13 +138,18 @@ has socket => ( sub _build_socket { my $self = shift; + my $socket; - while (!$socket) { + { $socket = IO::Socket::INET->new(PeerAddr => $self->host, PeerPort => $self->port); - Carp::carp "Couldn't connect to " . $self->host . ": $!" - unless $socket; + if (!$socket) { + Carp::carp "Couldn't connect to " . $self->host . ": $!"; + sleep 5; + redo; + } } + $socket->syswrite($self->establishment_message); return $socket; } |