The sendto function is used to send data on a SOCK_DGRAM socket type. The argument sock specifies a socket descriptor returned from a previous call to socket. The argument buf is a pointer to the application data buffer containing data to transmit. The buffer data length is not limited in size. If the data length is too large for one packet, the send function will fragment the data and send it in several successive data packets: - In blocking mode, which is enabled if the system detects RTX environment, this function returns after the data has been successfully transmitted.
- In non blocking mode, the function returns immediately without blocking the system. Return value represents the numbytes sent, which can be less than len, if the data can not be transmitted in one packet.
The argument len specifies the length of data in bytes. The argument flags specifies the message flags: | Flag | Description |
|---|
| MSG_DONTWAIT | The function returns with error code SCK_EWOULDBLOCK or numbytes sent instead of blocking the socket. |
The argument to is a pointer to the SOCKADDR structure that contains the end point node IP address and port number. The argument tolen specifies the length of SOCKADDR structure. The sendto function is in the RL-TCPnet library. The prototype is defined in rtl.h. note - You must call the socket function before any other function calls to the BSD socket.
- If a negative number is returned, it represents an error code.
|