Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Checking if remote exists before calling send

by bufo (Initiate)
on May 30, 2002 at 07:04 UTC ( [id://170324]=perlquestion: print w/replies, xml ) Need Help??

bufo has asked for the wisdom of the Perl Monks concerning the following question:

I have an application which sends and receives messages down a number of sockets. If I call send to a socket where the pc on which I need to send the message to has crashed and is re-booting then the program crashes out. Is there any way in which I can check the status of the socket or remote machine before doing the send?

Originally posted as a Categorized Question.

  • Comment on Checking if remote exists before calling send

Replies are listed 'Best First'.
Re: Checking if remote exists before calling send
by rasta (Hermit) on Oct 10, 2002 at 07:24 UTC
    I can advice you two solutions:

    1. Use SO_KEEPALIVE socket option like in the following example:
    use IO::Socket; my $sock = IO::Socket::INET->new('some_server'); $sock->read(1024,$data) until $sock->atmark;
    2. You may use NetPacket::ICMP to check if remote host is alive.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://170324]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2024-04-16 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found