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.

classification
Title: socket.recv() blocks while it's gettimeout() returns 0.0
Type: Stage: resolved
Components: Versions: Python 3.5, Python 2.7
process
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.

Files
File name Uploaded Description Edit
s1.py 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 127.0.0.1 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)
https://hg.python.org/cpython/rev/10e044a734f3

New changeset 7577960ea17b by Benjamin Peterson in branch '3.5':
merge 3.4 (#25471)
https://hg.python.org/cpython/rev/7577960ea17b

New changeset 347221cfa224 by Benjamin Peterson in branch 'default':
merge 3.5 (#25471)
https://hg.python.org/cpython/rev/347221cfa224
History
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: + s1.py
2015-10-24 23:14:30animussetfiles: - s1.py
2015-10-24 23:10:41animussetmessages: + msg253419
2015-10-24 23:03:29animuscreate