Asynchronous sending function, used to send data on a TCP/UDP socket.
Called by the application code when there is outgoing data available required to be sent on a specific socket handler. The only difference between this function and the similar sendto function, is the type of socket the data is sent on and the parameters passed in. send function is most commonly called for sockets in a connected state. After the data is sent, the socket callback function registered using registerSocketCallback(), is expected to receive an event of type SOCKET_MSG_SEND holding information containing the number of data bytes sent.
Functions | |
NMI_API sint16 | send (SOCKET sock, void *pvSendBuffer, uint16 u16SendLength, uint16 u16Flags) |
[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] | pvSendBuffer | Pointer to a buffer holding data to be transmitted. |
[in] | u16SendLength | The buffer size in bytes. |
[in] | u16Flags | Not used in the current implementation. |
For TCP Socket:
Must use a successfully connected Socket (so that the intended recipient address is known ahead of sending the data). Hence this function is expected to be called after a successful socket connect operation(in client case or accept in the the server case).
For UDP Socket:
UDP sockets most commonly use sendto function, where the destination address is defined. However, in-order to send outgoing data using the send function, at least one successful call must be made to the sendto function a priori the consecutive calls to the send function, to ensure that the destination address is saved in the firmware.
References M2M_REQ_DATA_PKT, MAX_SOCKET, NM_BSP_B_L_16, NULL, tstrSendCmd::sock, SOCK_ERR_BUFFER_FULL, SOCK_ERR_INVALID_ARG, SOCK_ERR_NO_ERROR, SOCKET_BUFFER_MAX_LENGTH, SOCKET_CMD_SEND, SOCKET_CMD_SSL_SEND, SOCKET_REQUEST, SSL_FLAGS_ACTIVE, SSL_FLAGS_DELAY, TCP_SOCK_MAX, TCP_TX_PACKET_OFFSET, tstrSocket::u16DataOffset, tstrSendCmd::u16DataSize, tstrSocket::u16SessionID, tstrSendCmd::u16SessionID, and UDP_TX_PACKET_OFFSET.
Referenced by handle_input_message().