summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-11-02 23:57:44 -0500
committerJesse Luehrs <doy@tozt.net>2010-11-02 23:57:44 -0500
commitfb4779c4da49301f8e85dcb72744de58b4f765e5 (patch)
tree7fce520de3ff1d1f8107114d57eb82f4e6fdba5a
parent0a2182e92bd6843f32a310630c4205073e0c2e3e (diff)
downloadapp-termcast-fb4779c4da49301f8e85dcb72744de58b4f765e5.tar.gz
app-termcast-fb4779c4da49301f8e85dcb72744de58b4f765e5.zip
don't try reconnecting immediately if it fails
-rw-r--r--lib/App/Termcast.pm11
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;
}