[docs] [issue12977] socket.socket.setblocking does not raise exception if no data available

Georg Brandl report at bugs.python.org
Sat Sep 17 20:27:49 CEST 2011

Georg Brandl <georg at python.org> 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 "<stdin>", line 1, in <module>
>>> s.setblocking(False)
>>> s.recv(10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
socket.error: [Errno 11] Resource temporarily unavailable

The corresponding server:

>>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> x.bind(('', 1234))
>>> x.listen(1)
>>> x.accept()
(<socket._socketobject object at 0x7f4211e997c0>, ('', 39146))

nosy: +georg.brandl
resolution:  -> works for me
status: open -> closed

Python tracker <report at bugs.python.org>

More information about the docs mailing list