sockets: client dies...

Donn Cave donn at oz.net
Wed Jan 24 22:52:24 EST 2001


Quoth Rick Lee <rwklee at home.com>:
| You should be able to tell on the recv().  It will throw an exception, not
| just return "no data".
|
| Here is from a piece of working code I have:
|
| try:
|     data = self.connection.recv(MaxBytes)
| except socket.error,v:

I misinterpreted that at first!  What you mean is, if the socket
isn't readable and would block, then if nonblocking it will
instead raise an exception (with v.errno == errno.EAGAIN);
when the socket closes, it becomes readable and then it will
return ''.  So the story is similar, even if for whatever
reason the socket has been set nonblocking.

	Donn



More information about the Python-list mailing list