Synopsis
CTL_STATUS_t ctl_tcp_recv(CTL_SOCKET_t s,
                          void *buf,
                          size_t bufLen,
                          CTL_TIMEOUT_t type,
                          CTL_TIME_t timeout);
Description

ctl_tcp_recv receives up to bufLen bytes into buf from socket soc.

Socket soc must first be in the connected state, CTL_TCP_SOCKET_STATE_CONNECTED, or ctl_tcp_recv will fail.

buf may be null, in which case up to bufLen bytes are discarded from the input stream.

The timeout value timeout can be zero to indicate a non-blocking call. If that is the case, this routine will retrieve as much data as it can (up to bufLen) from the socket and immediately return. In a blocking call, multiple passes across the task synchronization between the network task and the calling task may be required before the entire bufLen is received.

ctl_tcp_recv returns the count actually received for success or a standard CTL error code if the socket failed. A non-blocking call that received at least one byte but fewer than bufLen bytes is considered 'successful'.

Note

ctl_tcp_recv must not be called from the network task with a non-zero timeout. In other words, do not use the blocking version of this function in a TCP server callback.