cederom commented on PR #2595:
URL: https://github.com/apache/nuttx-apps/pull/2595#issuecomment-2367181133
Here is some reference on difference between `accept` and `accept4` [1]:
> accept4 is a non-standard linux extension. The real difference is in the
4th argument (flags) which is not present in accept.
> If flags is 0, then accept4() is the same as accept(). The following
values can be bitwise ORed in flags to obtain different behavior:
> `SOCK_NONBLOCK` Set the `O_NONBLOCK` file status flag on the new open
file description. Using this flag saves extra calls to
fcntl(2) to achieve the same result.
> `SOCK_CLOEXEC` Set the close-on-exec (`FD_CLOEXEC`) flag on the new
file descriptor. See the description of the `O_CLOEXEC` flag
in open(2) for reasons why this may be useful.
> By default, the new file descriptor is set to remain open across an
execve(2) (i.e., the FD_CLOEXEC file descriptor flag described in fcntl(2) is
initially disabled); the O_CLOEXEC flag, described below, can be used to change
this default.
> And for eg, by using this flag (SOCK_CLOEXEC), one can avoid race
conditions in multithreaded programs where it may lead to the file descriptor
returned by open() being unintentionally leaked to the program executed by the
child process created by fork(2).
Let me find some macOS machine.. and find the `accept4` in the headers
anywhere.. if there is none then @gneworld solution to wrap the call seems the
only one possible :-)
[1]
https://stackoverflow.com/questions/23952794/what-the-difference-between-accept4-and-accept
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]