From f7d2c39f20734d48a5306ac585f1bbee2fc2fbe7 Mon Sep 17 00:00:00 2001 From: minima Date: Sun, 4 Mar 2001 13:41:21 +0000 Subject: [PATCH] add a timeout to the outgoing connect --- perl/Msg.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/perl/Msg.pm b/perl/Msg.pm index 1099ba88..6702f152 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -51,6 +51,7 @@ sub new state => 0, lineend => "\r\n", csort => 'telnet', + timeval => 60, }; return bless $conn, $class; @@ -61,20 +62,22 @@ sub new sub connect { my ($pkg, $to_host, $to_port, $rproc) = @_; + # Create a connection end-point object + my $conn = $pkg; + unless (ref $pkg) { + $conn = $pkg->new($rproc); + } + # Create a new internet socket my $sock = IO::Socket::INET->new ( PeerAddr => $to_host, PeerPort => $to_port, Proto => 'tcp', - Reuse => 1); + Reuse => 1, + Timeout => $conn->{timeval} / 2); return undef unless $sock; - # Create a connection end-point object - my $conn = $pkg; - unless (ref $pkg) { - $conn = $pkg->new($rproc); - } $conn->{sock} = $sock; if ($conn->{rproc}) { -- 2.43.0