Set a socket to accept incoming connections. The socket must already be bound to a local address. If successful, incoming TCP connection requests addressed to the socket’s local address will be queued until accepted by the socket (see section C-13-1 “NetSock_Accept() / accept() (TCP)”).
Files
net_sock.h/net_sock.c
net_bsd.h/net_bsd.c
Prototypes
Arguments
sock_id
This is the socket ID returned by NetSock_Open()/socket()
when the socket was created.
sock_q_size
Maximum number of new connections allowed to be waiting. In other words, this argument specifies the maximum queue length of pending connections while the listening socket is busy servicing the current request.
perr
Pointer to variable that will receive the return error code from this function:
NET_SOCK_ERR_NONE
NET_SOCK_ERR_NOT_USED
NET_SOCK_ERR_CLOSED
NET_SOCK_ERR_INVALID_SOCK
NET_SOCK_ERR_INVALID_FAMILY
NET_SOCK_ERR_INVALID_PROTOCOL
NET_SOCK_ERR_INVALID_TYPE
NET_SOCK_ERR_INVALID_STATE
NET_SOCK_ERR_INVALID_OP
NET_SOCK_ERR_CONN_FAIL
NET_CONN_ERR_NOT_USED
NET_CONN_ERR_INVALID_CONN
NET_ERR_INIT_INCOMPLETE
NET_OS_ERR_LOCK
Returned Value
NET_SOCK_BSD_ERR_NONE/0
, if successful;
NET_SOCK_BSD_ERR_LISTEN/-1
, otherwise.
Required Configuration
NetSock_Listen()
is available only if either NET_CFG_TRANSPORT_LAYER_SEL
is configured for TCP (see section D-12-1) and/or NET_UDP_CFG_APP_API_SEL
is configured for sockets (see section D-13-1).
In addition, listen()
is available only if NET_BSD_CFG_API_EN
is enabled (see section D-17-1).
Notes / Warnings
None.