sockets: client dies...

Donn Cave donn at u.washington.edu
Tue Jan 23 16:18:45 EST 2001


Quoth Keith Murphy <kpmurphy at my-deja.com>:
| what can you do when the client dies in a client/server socket
| relationship?  currently, my problem is that the server doesn't know
| when a client has terminated unexpectedly.  is there any way to do so?

Ideally, that will close the socket.  If that happens, then the
socket becomes "readable" - that is, a recv() will return immediately
without blocking, returning '' (empty string.)   (I'm assuming the
socket is blocking, per default.)

I don't know any way to tell the difference between "closed" and "has
data", prior to calling recv().  But you can tell the difference between
readable and "would block" prior to recv(), with select().

If the client dies and the socket doesn't close, then it may be worth
while to figure out why it doesn't.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list