Georg Brandl added the comment:
I think you're mistaking a closed connection with "no data available".
Small demo that this works as intended:
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.connect(('localhost', 1234))
>>> s.recv(10)
^CTraceback (most recent call last):
File
New submission from Florian Ludwig :
The documentation states:
> In non-blocking mode, if a recv() call doesn’t find any data, [...], a error
> exception is raised; [0]
Which is wrong. If no data is available recv() does not raise an exception but
returns an empty string.
[0] http://docs.pyt