Embedded TCP/IP stack  4.7.0

◆ fnet_socket_send()

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

Sends the data on a connected socket.

Parameters
sDescriptor, identifying a connected socket.
bufBuffer containing the data to be transmitted.
lenLength of the data in 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 total number of bytes sent, if no error occurs. It can be less than the number indicated by len.
  • 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_sendto()

For stream-oriented sockets (SOCK_STREAM), the number of actually sent bytes can be between 0 and the requested length, depending on buffer availability on both client and server machines.

For message-oriented sockets (SOCK_DGRAM), care must be taken not to exceed the maximum datagram size, which can be obtained by using the fnet_socket_getopt() to retrieve the value of the socket option SO_SNDBUF. If the data is too long to pass atomically through the underlying datagram protocol, the error FNET_ERR_MSGSIZE is returned and no data is transmitted.
Calling the fnet_socket_send() with a zero len parameter is permissible. In such cases, the fnet_socket_send() will return zero as a valid value, and for message-oriented sockets (SOCK_DGRAM) a zero-length transport datagram is sent.

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