sendmsg

Top  Previous  Next

The sendmsg function sends a message through a connection-oriented or connection-less socket. If the socket is connection-less, the message is send to the address specified by msghdr. If the socket is connection-oriented, the destination address in msghdr is ignored.

 

Syntax

ssize_t sendmsg(

int socket,

const struct msghdr *msg,

int flags

);

 

Parameters

socket

The descriptor that identifies a connected socket.

 

msg

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. Values of this argument are formed by logically OR'ing zero or more of the following flags:

 

Type

Meaning

MSG_OOB

Sends out-of-band data in sockets that support out of band communications. The significance and semantics of out-of band data are protocol-specific.

MSG_WAITALL

Terminates a record (if supported by the protocol).

 

 

Return value

Upon successful completion, sendmsg returns the number of bytes sent. Otherwise, -1 is returned and errno set to indicate the error.