Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
accept(2) OSS System Calls Reference Manual
NAME
accept - Accepts a new connection on a socket
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
SYNOPSIS
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/socket.h>
int accept(
int socket,
struct sockaddr *address,
socklen_t *address_len);
PARAMETERS
socket Specifies the file descriptor for a socket that was created with the socket() func-
tion, has been bound to an address with the bind( ) function, and has issued a
successful call to the listen() function.
address Specifies either a null pointer or a pointer to the sockaddr structure where the
address of the peer socket that requested the connection should be returned. The
length and format of the address depend on the address family of the socket.
For AF_INET sockets, a pointer to the address structure sockaddr_in must be
cast as a struct sockaddr.ForAF_INET6 sockets, a pointer to the address
structure sockaddr_in6 must be cast as a struct sockaddr.ForAF_UNIX sock-
ets, a pointer to the address structure sockaddr_un must be cast as a struct
sockaddr.
address_len Points to a socklen_t data item, which, on input, specifies the length of the
sockaddr structure pointed to by the address parameter, and, on output, specifies
the length of the address returned.
DESCRIPTION
The accept() function extracts the first connection on the queue of pending connections, creates
a new socket with the same socket type, protocol, and address family as the specified socket, and
allocates a new file descriptor for that socket.
In systems running AF_UNIX Release 2 software, the new socket will use the same mode (com-
patibility or portability) as the specified socket.
For more information about AF_UNIX Release 2, compatibility mode, and portability mode, see
the Open System Services Programmer’s Guide.
When the accept() function is called using a value for the address parameter that is null, suc-
cessful completion of the call returns a socket file descriptor without modifying the value pointed
to by the address_len parameter. When the accept() function is called using a value for the
address parameter that is not null, a successful call places the address of the peer socket in the
sockaddr structure pointed to by the address parameter, and places the length of the peer
socket’s address in the location pointed to by the address_len parameter.
If the length of the socket address is greater than the length of the supplied sockaddr structure,
the address is truncated when stored.
1−2 Hewlett-Packard Company 527186-023