accept.2 (2010 09)

a
accept(2) accept(2)
X/Open Sockets Compilation Environment
See xopen_networking(7).
RETURN VALUE
Upon successful completion,
accept() returns a nonnegative integer which is a descriptor for the
accepted socket.
If an error occurs,
accept() returns -1 and sets
errno to indicate the cause.
ERRORS
If
accept() fails, errno is set to one of the following values:
[EAGAIN] Nonblocking I/O is enabled using
O_NONBLOCK and no connections are present to
be accepted.
[EBADF] The argument, s, is not a valid file descriptor.
[ECONNABORTED] The socket is being shutdown due to a request by software. This is usually caused
by a
shutdown() system call.
[EFAULT] The addr parameter is not a valid pointer.
[EINTR] The call was interrupted by a signal before a valid connection arrived.
[EINVAL] The socket referenced by s is not currently a listen socket or has been shut down
with
shutdown().Alisten() must be done before an accept() is allowed.
[EMFILE] The maximum number of file descriptors for this process are currently open.
[ENFILE] The system’s table of open files is full and no more
accept() calls can be pro-
cessed at this time.
[ENOBUFS] No buffer space is available. The
accept() cannot complete. The queued socket
connect request is aborted.
[ENOMEM] No memory is available. The
accept() cannot complete. The queued socket con-
nect request is aborted.
[ENOTSOCK] The argument, s, is a valid file descriptor, but it is not a socket.
[EOPNOTSUPP] The socket referenced by s does not support
accept().
[EWOULDBLOCK] Nonblocking I/O is enabled using
O_NDELAY or FIOSNBIO and no connections are
present to be accepted.
OBSOLESCENCE
Currently, the
socklen_t and size_t types are the same size. This is compatible with the UNIX 95
and UNIX 03 profiles. However, in a future release, socklen_t might be a different size. In that case,
passing a size_t pointer will evoke compile-time warnings, which must be corrected in order for the
application to behave correctly. Applications that use socklen_t now, where appropriate, will avoid
such migration problems. On the other hand, applications that need to be portable to the UNIX 95 profile
should follow the X/Open specification (see xopen_networking(7)).
WARNINGS
Linking binary objects compiled to X/Open Sockets specification and binary objects compiled to HP-UX
BSD Sockets specification to the same executable may result in unexpected behavior, including applica-
tion abnormal termination and unexpected socket errors. See xopen_networking(7) for details and
remedy.
FUTURE DIRECTION
Currently, the default behavior is the HP-UX BSD Sockets; however, it might be changed to X/Open
Sockets in a future release. At that time, any HP-UX BSD Sockets behavior that is incompatible with
X/Open Sockets might be obsoleted. Applications that conform to the X/Open specification now will
avoid migration problems (see xopen_networking(7)).
AUTHOR
accept() was developed by HP and the University of California, Berkeley.
2 Hewlett-Packard Company − 2 − HP-UX 11i Version 3: September 2010