[Bug 279871] recv(2) on tcp socket with O_NONBLOCK returns 0 after connection reset
Date: Thu, 20 Jun 2024 05:55:08 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279871
Bug ID: 279871
Summary: recv(2) on tcp socket with O_NONBLOCK returns 0 after
connection reset
Product: Base System
Version: 14.0-RELEASE
Hardware: Any
OS: Any
Status: New
Severity: Affects Many People
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: richard@annexi-strayline.com
I am observing that when invoking recv(2) on a TCP socket (taken from
listen(2)), where O_NONBLOCK is set, and the remote peer closes the connection,
recv continues to return 0 forever.
The recv(2) man page says:
"If no messages are available at the socket, the receive call waits for a
message to arrive, unless the socket is non-blocking (see fcntl(2)) in which
case the value -1 is returned and the global variable errno is set to EAGAIN."
It seems in this case we would expect -1 + EAGAIN for a non-blocking socket
where the connection has been reset.
This was tested with a small program reading from a socket that was written to
via telnet from localhost. Each call to recv is given a 3-byte buffer.
I am not sure when this behavior began..
--
You are receiving this mail because:
You are the assignee for the bug.