This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: socket.recv() blocks while it's gettimeout() returns 0.0
Type: Stage: resolved
Components: Versions: Python 3.5, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: animus, python-dev
Priority: normal Keywords:

Created on 2015-10-24 23:03 by animus, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit animus, 2015-10-24 23:14
Messages (3)
msg253418 - (view) Author: Alexey Gorshkov (animus) Date: 2015-10-24 23:03
socket created with listening socket set to setblocking(False). gettimeout() of accept()-returned socket returns 0.0 , but recv() method blocks while client is connected and not sending any data. If client disconnects, socket returned by accept() starting return 0-length bytes string without blocking.

glibc doc on recv():
If nonblocking mode is set for SOCKET, and no data are available to be read, 'recv' fails immediately rather than waiting.

testing server and client code attached.

tested with Python 3.5.0 and Python 2.7.10
msg253419 - (view) Author: Alexey Gorshkov (animus) Date: 2015-10-24 23:10
telnet 9000 can be used as testing client
msg253420 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-10-25 03:07
New changeset 10e044a734f3 by Benjamin Peterson in branch '3.4':
accepted sockets shouldn't inherit the SOCK_NONBLOCK flag (closes #25471)

New changeset 7577960ea17b by Benjamin Peterson in branch '3.5':
merge 3.4 (#25471)

New changeset 347221cfa224 by Benjamin Peterson in branch 'default':
merge 3.5 (#25471)
Date User Action Args
2022-04-11 14:58:23adminsetgithub: 69657
2015-10-25 03:07:43python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg253420

resolution: fixed
stage: resolved
2015-10-24 23:14:47animussetfiles: +
2015-10-24 23:14:30animussetfiles: -
2015-10-24 23:10:41animussetmessages: + msg253419
2015-10-24 23:03:29animuscreate