dsb has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to open a socket to a service, send a message and receive a response. With the following code, I can do just that:
dsb
This @ISA my( $cool ) %SIG
The trouble is that if the service is not functioning properly it does not respond, and so the call to recv hangs. It's okay if the server doesn't respond (that's kind of the point of this little smoke test), but I need to just get an empty response and move on...my $sock = IO::Socket::INET->new( PeerAddr => '10.0.0.1', PeerPort => '22222', Proto => 'tcp', ); print "Connection to 22010 is open\n" if $sock->connected(); my $buf; $sock->send( $msg ); $sock->recv( $buf, 200 ); print "Message: $msg\n"; print "Response: $buf\n"; $sock->close();
Thoughts?
dsb
This @ISA my( $cool ) %SIG
Back to
Seekers of Perl Wisdom