Embedded TCP/IP stack  4.7.0

◆ fnet_socket_recv()

fnet_ssize_t fnet_socket_recv ( fnet_socket_t  s,
void *  buf,
fnet_size_t  len,
fnet_flag_t  flags 
)

Receives the data from a connected socket.

Parameters
sDescriptor identifying a connected socket.
bufBuffer for the incoming data.
lenLength of the buf.
flagsOptional flag specifying the way, in which the call is made. It can be constructed by using the bitwise OR operator with any of the values defined by the fnet_msg_flags_t.
Returns
This function returns:
  • The number of bytes received, if no error occurs. The return value is set to zero, if there is no input data.
  • FNET_ERR if an error occurs.
    The specific error code can be retrieved using the fnet_error_get().
See also
fnet_socket_connect(), fnet_socket_recvfrom()

For connection-oriented sockets (SOCK_STREAM), calling the fnet_socket_recv() will return as much information as is currently available up to the size of the buffer supplied.

For connectionless sockets (SOCK_DGRAM), the data is extracted from the first enqueued datagram (message), whose destination address is specified by the fnet_socket_connect() function. If the datagram is larger than the supplied buffer, the buffer is filled with the first part of the datagram, and the fnet_socket_recv() generates the error FNET_ERR_MSGSIZE and the excess data is lost.

The flags parameter can be used to influence the behavior of the function invocation beyond the options specified for the associated socket.


© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net