![]() |
WINC1500 IoT Software APIs
19.5.2
WINC Software API Reference Manual
|
Functions | |
NMI_API sint8 | listen (SOCKET sock, uint8 backlog) |
Detailed Description
After successful socket binding to an IP address and port on the system, start listening on a passive socket for incoming connections. The socket must be bound on a local port or the listen operation fails. Upon the call to the asynchronous listen function, response is received through the event SOCKET_MSG_BIND in the socket callback. A successful listen means the TCP server operation is active. If a connection is accepted, then the application socket callback function is notified with the new connected socket through the event SOCKET_MSG_ACCEPT. Hence there is no need to call the accept function after calling listen.
After a connection is accepted, the user is then required to call the recv to receive any packets transmitted by the remote host or to receive notification of socket connection termination.
Function Documentation
◆ listen()
- Parameters
-
[in] sock Socket ID, must hold a non negative value. A negative value will return a socket error SOCK_ERR_INVALID_ARG. Indicating that an invalid argument is passed in. [in] backlog Not used by the current implementation.
- Precondition
- The bind function must be called to assign the port number and IP address to the socket before the listen operation.
- Returns
- The function returns ZERO for successful operations and a negative value otherwise. The possible error values are:
- SOCK_ERR_NO_ERROR Indicating that the operation was successful.
- SOCK_ERR_INVALID_ARG Indicating passing invalid arguments such as negative socket ID.
- SOCK_ERR_INVALID Indicate socket listen failure.
Example
This example demonstrates the call of the listen socket operation after a successful socket operation.
Generated on Thu Jan 26 2017 22:15:21 for WINC1500 IoT Software APIs by
