iang has asked for the wisdom of the Perl Monks concerning the following question:
However when I run it from the script below it hangs. I belive it is because I am waiting for input on my socket, but none ever comes. To get around this, I set an alarm for 1 second then print exit In the current form, it hangs for ever. If I uncomment the alarm parts, it works fine.use IO::Socket::INET; my $port = 10405; my $host = 'server'; my $socket = IO::Socket::INET->new(PeerAddr => "$host", PeerPort => $port, Proto => "tcp", timeout => 3, Type => SOCK_STREAM) || die " +Could not establish connection : $!\n"; #$SIG{ALRM} = sub { print $socket "exit\n" }; my $header = <$socket>; print $socket "status"; #alarm(1); while(<$socket>) { chomp; print "$_\n"; } print "out of loop\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: telnet to a vendor app hangs
by VSarkiss (Monsignor) on Sep 15, 2006 at 19:57 UTC | |
by iang (Sexton) on Sep 15, 2006 at 20:22 UTC | |
by jdtoronto (Prior) on Sep 15, 2006 at 20:25 UTC | |
by VSarkiss (Monsignor) on Sep 15, 2006 at 21:21 UTC | |
by fmerges (Chaplain) on Sep 16, 2006 at 11:31 UTC | |
Re: telnet to a vendor app hangs
by aquarium (Curate) on Sep 16, 2006 at 14:58 UTC |