CTL_STATUS_t ctl_tcp_send(CTL_SOCKET_t s, const void *buf, size_t len, CTL_TIMEOUT_t type, CTL_TIME_t timeout, unsigned flags);
ctl_tcp_send sends len bytes from buf to socket s. Socket s must first be in the connected state, CTL_TCP_SOCKET_STATE_CONNECTED, or ctl_tcp_send fails.
Setting the timeout value ms to zero indicates a non-blocking call. In this case, as much data as possible will be passed to the MAC before returning. In a blocking call, multiple passes across the task synchronization between the network task and the calling task may be required before the entire len is sent.
Parameter flags may be zero or a bitwise combination of the following:
Using the network library, the application layer has complete control over packet send coalescing. If the CTL_TCP_SEND_PUSH flag is not set, then an outgoing packet is only sent when a complete TCP segment has been built up. The CTL_TCP_SEND_PUSH flag will cause the buf and any previous queued send data to be sent to the remote TCP.
If flags is CTL_TCP_SEND_PUSH, buf may be null or len may be zero; in that case all previous queued data is sent on its way to the remote TCP.
ctl_tcp_send returns the count of bytes actually sent for success or a negative value for fail. A non-blocking call (timeout is zero) that sent at least one byte but less than len bytes is considered successful.
ctl_tcp_send should not be invoked from the network task with a non-zero timeout value. In other words, do not use the blocking version of this function in a TCP server callback.