int accept(int sockfd, const struct sockaddr *addr, int *addrlen, int flags);
This syscall takes the first connection request of sockfd
and creates
a new connected socket with the flags in flags
(SOCK_NONBLOCK
and
SOCK_CLOEXEC
). addr
is used for writing the address of the
connection request. addrlen
must be the length of the available buffer,
and it will be written to be the actual length copied.
The syscall returns the added FD on success or -1
on failure, with the
following errno:
EINVAL
: Invalid value for backlog.
EBADFD
: The passed FD is not a socket and listening.
ENOTSUPP
: The passed FD is a socket, but it is not a stream socket.