Stupid Q: asyncore and disconnecting?

Stephen Hansen stephen at cerebralmaelstrom.com
Sat Oct 7 03:28:56 EDT 2000


Hmm, I was using handle_read(), could that be the cause of my error?
What is the difference between handle_read() and handle_read_event()?

Thanks.

In article <TeUC5.3582$q9.174181 at news-west.usenetserver.com>,
kragen at dnaco.net (Kragen Sitaker) wrote:

> In article <20001004.192340.98221 at Jeremy.cerebralmaelstrom.com>, Stephen
> Hansen <stephen at cerebralmaelstrom.com> wrote:
>>Okay, I am using asyncore to make a little server, and am wondering how
>>to go about detecting a client disconnected? When I 'telnet' into it,
>>then close the connection, the server doesn't know its closed, each
>>read/poll still receives just balnk data..... and, shouldn't it not try
>>to read if there is nothing to be read?
> 
> A closed socket selects as readable, so you get handle_read_event(); but
> when you try to read it, the read returns 0.  I believe that that is the
> only time read on a socket will ever return 0.  (When I tried it,
> reading from a nonblocking socket that was open, but had no data coming
> in, raised an exception.)



More information about the Python-list mailing list