Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCP/IP Sockets programming query 1

Status
Not open for further replies.

stuf77

Programmer
Jul 20, 2002
5
GB
Hi,

Hopefully somebody out there can answer this question:

If a client application crashes/dies, is there any way the server application would notice?

i.e. if a server application has forked a child process to deal with a given client app's requests and, after a few request/response transactions over the dedicated socket connection, the client dies, is the server child process told about it in any way? Or have we just effectively leaked a process?!!

Please help! [sadeyes]
 
The client's operating system should close the socket when the client application dies. If it does, the server should notice the disconnect.

If the connection is not closed (for whatever reason), then the server would get a RST (aka Connection Reset by Peer) the next time it attempted to send data to the client.

If your server application only sends messages in response to client messages, and the client considers the connection closed while the server considers it connected (this is sometimes called "a stale socket"), the server will sit and wait for messages that will never arrive. The exception to this is if the server's operating system uses TCP "keep-alives" (RFC 1122).

You can avoid the 'stale socket' problem by either implementing a time-out or a keep-alive message of your own.

Hope that helps,
Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top