Embedded TCP/IP stack
4.7.0
|
fnet_socket_t fnet_socket_accept | ( | fnet_socket_t | s, |
struct fnet_sockaddr * | addr, | ||
fnet_size_t * | addrlen | ||
) |
Accepts a connection on the specified socket.
s | Descriptor, identifying an unconnected socket. |
addr | Optional pointer to a buffer that receives the address of the remote host at the other end of the connection. |
addrlen | Optional pointer to an integer that contains the length of the addr parameter. |
The function extracts the first connection in the queue of pending connections on the listening socket s
, and returns the new socket descriptor.
The newly-created socket is the socket that will handle the actual connection and has the same properties as the socket s
. The original socket remains open and listens for new connection requests. If no pending connections are present in the queue of the socket, the fnet_socket_accept() returns FNET_NULL and the specific error code is set to FNET_ERR_AGAIN.
The parameter addr
is a result parameter that is filled in with the address of the remote host. The addrlen
should initially contain the amount of space pointed to by the addr
; on return it will contain the actual length of the address returned (in bytes).
The fnet_socket_accept() function is used only with connection-oriented socket types (SOCK_STREAM).
If addr
and/or addrlen
are equal to 0
, then no information about the remote address of the accepted socket is returned.