Accepts a connection on the specified socket.
- Parameters
-
| 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. |
- Returns
- This function returns:
- Socket descriptor referencing the new socket, if no error occurs.
- FNET_NULL if an error occurs.
The specific error code can be retrieved using fnet_error_get().
- See also
- fnet_socket(), fnet_socket_bind()
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.