You are here : Csys/socket.hsendmsg

sendmsg() - sys/socket.h

The sendmsg() function sends a message through a connection-mode or connectionless-mode socket. If the socket is connectionless-mode, the message will be sent to the address specified bymsghdr. If the socket is connection-mode, the destination address in msghdr is ignored.

Parameter :

  • socket - Specifies the socket file descriptor.
  • message - Points to a msghdr structure, containing both the destination address and the buffers for the outgoing message. The length and format of the address depend on the address family of the socket. The msg_flags member is ignored.
  • flags - Specifies the type of message transmission. The application may specify 0 or the following flag:
    • MSG_EOR - Terminates a record (if supported by the protocol)
    • MSG_OOB - Sends out-of-band data on sockets that support out-of-bound data. The significance and semantics of out-of-band data are protocol-specific.


Syntax

#include <sys/socket.h>

ssize_t sendmsg (int socket, const struct msghdr *message, int flags);


Example

#include <sys/socket.h>

ssize_t sendmsg (int socket, const struct msghdr *message, int flags);


Output / Return Value

Upon successful completion, sendmsg() function returns the number of bytes sent.

Otherwise, -1 is returned and errno is set to indicate the error.


Limitations


Alternatives / See Also


Reference

  1. http://pubs.opengroup.org/onlinepubs/7908799/xns/sendmsg.html