NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Non-blocking socket bug



=> On Sat, 26 Oct 2019 15:20:42 -0500
=> Edgar Pettijohn <edgar%pettijohn-web.com@localhost> wrote:
=>
=>>
=>> On Oct 26, 2019 2:44 PM, Sad Clouds <cryintothebluesky%gmail.com@localhost>
=>> wrote:
=>> >
=>> > I've come across an issue when testing networking code, which looks
=>> > like a bug. This is on NetBSD-8.1
=>> >
=>> > When a listening socket is set non-blocking and we call accept() on
=>> > that socket, the new socket returned by accept() will also be
=>> > non-blocking.
=>> >
=>> > I think this is a bug. I thought all new sockets/file descriptors
=>> > would be non-blocking by default. I've attached a test program to
=>> > demonstrate the issue.
=>>
=>> That is how the manual describes it to be.
=>
=> Can you be more specific please, which manual and which case does it
=> describe, accept() returning blocking or non-blocking socket?
=>
=> I'm not sure at this stage if this is a bug or BSD specific feature.
=>

https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_10_07

2.10.7 Socket I/O Mode
The I/O mode of a socket is described by the O_NONBLOCK file status flag
which pertains to the open file description for the socket. This flag is
initially off when a socket is created, but may be set and cleared by the
use of the F_SETFL command of the fcntl() function.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html

DESCRIPTION
The accept() function shall extract the first connection on the queue of
pending connections, create a new socket with the same socket type
protocol and address family as the specified socket, and allocate a new
file descriptor for that socket.

   So accept() creates a socket, and O_NONBLOCK is initially off when a
socket is created, so it should be off.

                               Gary Duzan





Home | Main Index | Thread Index | Old Index