The send function is used to send data on an already connected socket. This function is normally used to send a reliable, ordered stream of data bytes on a SOCK_STREAM socket type. It can also be used to send datagrams on a SOCK_DGRAM socket types. 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 send 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.
|