A closed client socket appended into elist, but there is no exception in ex when select called. I don’t known why, can you help me please. Thanks so much!
r,w,ex = select.select(rlist, wlist,elist )
for s in ex:
print "catch a closed socket error!"
To catch a socket being closed event you need to have the socket in
rlist. When a connection is closed on the other side,selectreturns and denotes that the closed socket is ready for reading (i.e. it’s in yourlist). If you performrecvon this socket and it returns an empty list (nothing has been read), it means a connection has been closed.From what I have seen, the exception list (the last parameter of select) isn’t widely used. The main problem with it is that different OSes interpret this parameter differently. Sometimes it’s even used only for cases that don’t seem to be exceptions at all (OOB data).
socketmodule documentation isn’t specific about what that argument means, so it’s generally not a good idea to rely on it: