![]() |
WINC1500 IoT Software APIs
19.5.2
WINC Software API Reference Manual
|
Functions | |
NMI_API sint8 | connect (SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen) |
Detailed Description
Establishes a TCP connection with a remote server. The asynchronous connect function must be called after receiving a valid socket ID from the socket function. The application socket callback function is notified of a successful new socket connection through the event SOCKET_MSG_CONNECT. A successful connect means the TCP session is active. The application is then required to make a call to the recv to receive any packets transmitted by the remote server, unless the application is interrupted by a notification of socket connection termination.
Function Documentation
◆ connect()
- 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] pstrAddr Address of the remote server. [in] pstrAddr Pointer to socket address structure "sockaddr_in" sockaddr_in [in] u8AddrLen Size of the given socket address structure in bytes. Not currently used, implemented for BSD compatibility only.
- Precondition
- The socket function must be called to allocate a TCP socket before passing the socket ID to the bind function. If the socket is not bound, you do NOT have to call bind before the "connect" function.
- 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 or NULL socket address structure.
- SOCK_ERR_INVALID Indicate socket connect failure.
Example
The example demonstrates a TCP application, showing how the asynchronous call to the connect function is made through the main function and how the callback function handles the SOCKET_MSG_CONNECT event.
UDP example
TCP example
Generated on Thu Jan 26 2017 22:15:21 for WINC1500 IoT Software APIs by
