Python sockets/select

Gordon McMillan gmcm at hypernet.com
Wed Jun 21 18:34:08 EDT 2000


[posted and mailed]

David Allen wrote:

>When I select() sockets for reading, writing, and error conditions,
>there are sockets (usually connected to clients who have already
>quit or died unexpectedly) that don't show up in the error queue,
>but continually flag select() as being readable.  When I read them,
>of course, '' comes back.

Using Windows, huh? Donn gave you the correct answer for real OSes, but 
Windows does some things, um, differently. AFAICT, the error list is 
useless on Windows.

>For some reason, sometimes '' comes in for valid clients, so I 
>can't just disconnect a client because I get that from them.  

Other than protocol-eating nano-viruses, this shouldn't happen.

Note that, on Windows, select can return a socket as writable, but when you 
go to write it, you get an EWOULDBLOCK (10035 in the Gates scheme). But in 
my experience, getting 0 bytes on read means that sucker's dead.

(Well, a socket ready to accept() also returns as readable, but of course, 
can't be read yet.)

- Gordon



More information about the Python-list mailing list