Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How can I make a client realize the server connection is gone?

by zigster (Hermit)
on Apr 19, 2001 at 12:16 UTC ( [id://73772]=note: print w/replies, xml ) Need Help??


in reply to How can I make a client realize the server connection is gone?

If the server closes the connection you should recieve an EOF on the socket. HOWEVER, tcp is designed to run over very slow and lossy networks, it is hard to tell the difference between a very slow/lossy network and a dead server.. In fact in tcp terms it is impossible. TCP works on a series of timeouts EVENTUALLY it will work out that the server is dead but it will take a long time.
Having said all that things to consider.
  • Write a ping method into your server, get it to send a datagram every n seconds. If the client does not recieve that datagram then you know the server is dead.
  • Look at the socket option SO_KEEPALIVE this will implement a ping protocol for you, however its timeouts are huge. 2 Hours or more, you can change this time out on a persystem basis (exactly how depends upon the system), you cannot do this AFAIK on a per connection basis.

For more information on this topic have a look at the UNIX Socket FAQ This document is as relivent to perl as it is to C, dont be put off by the fact that the examples are all in C. TCP is TCP is TCP.
  • Comment on Re: How can I make a client realize the server connection is gone?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found