NAME
spines_accept - Accepts a connection on a Spines socket
SYNOPSIS
#include "spines_lib.h"
int spines_accept(int s, struct sockaddr *addr,
socklen_t *addrlen);
DESCRIPTION
The accept function is used with connection-based socket types
(SOCK_STREAM). It extracts the first connection request on the
queue of pending connections, creates a new connected socket
with mostly the same properties as s, and allocates a new file
descriptor for the socket, which is returned. The newly created
socket is no longer in the listening state. The original socket
s is unaffected by this call.
The argument s is a socket that has been created with
spines_socket, bound to a local address with spines_bind, and
is listening for connections after a spines_listen.
The argument addr is a pointer to a sockaddr structure. This
structure is filled in with the address of the connecting
entity, as known to the communications layer. The addrlen
argument is a value-result parameter: it should initially
contain the size of the structure pointed to by addr; on return
it will contain the actual length (in bytes) of the address
returned. When addr is NULL nothing is filled in.
If no pending connections are present on the queue, accept
blocks the caller until a connection is present.
In order to be notified of incoming connections on a socket,
you can use select or poll. A readable event will be delivered
when a new connection is attempted and you may then call accept
to get a socket for that connection.
RETURN VALUE
The call returns -1 on error. If it succeeds, it returns a
non-negative integer that is a descriptor for the accepted
socket.