Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 ( #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? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2022-01-25 16:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (67 votes). Check out past polls.

    Notices?