Asynchronous bind function associates the provided address and local port to the socket.
The function can be used with both TCP and UDP sockets. It is mandatory to call the bind function before starting any UDP or TCP server operation. Upon socket bind completion, the application will receive a SOCKET_MSG_BIND message in the socket callback.
Functions | |
NMI_API sint8 | bind (SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen) |
[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 | Pointer to socket address structure sockaddr_in. |
[in] | u8AddrLen | Size of the given socket address structure in bytes. |
This example demonstrates the call of the bind socket operation after a successful socket operation.
References m2m_memcpy(), MAX_SOCKET, NULL, tstrBindCmd::sock, SOCK_ERR_INVALID, SOCK_ERR_INVALID_ARG, SOCK_ERR_NO_ERROR, SOCKET_CMD_BIND, SOCKET_CMD_SSL_BIND, SOCKET_REQUEST, SSL_FLAGS_ACTIVE, tstrBindCmd::strAddr, tstrSocket::u16SessionID, and tstrBindCmd::u16SessionID.