Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (s and S) spt_acceptx(2)
NAME
spt_acceptx - Accepts a new connection on a socket (thread-aware version)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series and J series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <sys/socket.h>]
#include <spthread.h>
int spt_acceptx(
int socket,
struct sockaddr *address,
size_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 size_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 spt_acceptx() function is a thread-aware version of the accept() function.
The spt_acceptx() 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.
When the spt_acceptx() function is called using a value for the address parameter that is null,
successful completion of the call returns a socket file descriptor without modifying the value
pointed to by the address_len parameter. When the spt_acceptx() 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.
If the queue of pending connections is empty of connection requests and the socket’s file
descriptor is blocking (O_NONBLOCK is not set), the spt_acceptx() function blocks until a
connection is present. If the socket’s file descriptor is marked nonblocking (O_NONBLOCK is
set) and the queue of pending connections is empty, the spt_acceptx() function call fails and sets
errno to [EWOULDBLOCK].
527186-023 Hewlett-Packard Company 7−131