sendmsg()

send message from socket using structure 

Function


SYNOPSIS

#include <sys/socket.h>

int sendmsg(int s, const struct msghdr *msg, int flags);


DESCRIPTION

The sendmsg() function sends a message through a connection oriented or connectionless socket. If s is a connectionless socket, the message is sent to the address specified by msghdr. If s is a connection oriented socket, the destination address in msghdr is ignored.

If the message is too long to pass through the underlying protocol, sendmsg() fails and no data is transmitted.

Successful completion of sendmsg() does not guarantee delivery of the message. A return value of -1 indicates only locally-detected errors.

If space is not available at the sending socket to hold the message to be transmitted and the socket file descriptor does not have O_NONBLOCK set, sendmsg() blocks until space is available. If space is not available at the sending socket to hold the message to be transmitted and the socket file descriptor does have O_NONBLOCK set, sendmsg() fails. Use the select() call to determine when more data can be sent.

flags may be used to influence the behavior of the function invocation beyond the options specified for the associated socket. That is, the semantics of this function are determined by the socket options and the flags parameter. The latter is constructed by OR-ing any of the following values:

MSG_DONTROUTE  

Specifies that the data should not be subject to routing.

MSG_OOB  

Send out-of-band data (stream-style socket such as SOCK_STREAM only).


PARAMETERS

s 

Specifies a socket descriptor.

message 

Points to a msghdr structure which contains both a pointer to the buffer containing the destination address, and the address of the buffers which contains the message to be transmitted. The msg_flags field is ignored.

flags 

Lets the sender control the way data is sent.


RETURN VALUES

If successful, sendmsg() returns the number of characters sent. If an error occurs, it returns a value of -1 and sets errno to one of the following:

EADDRNOTAVAIL 

The specified address is not available from the local machine.

EBADF 

s is an invalid descriptor.

ECONNABORTED 

Connection was aborted due to timeout or other failure.

ECONNRESET 

Connection was forcibly reset by the peer.

EDESTADDRREQ 

A destination address is required.

EFAULT 

msg points to an unreadable location.

EHOSTUNREACH 

The remote host cannot be reached from this host at this time.

EINVAL 

An unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled.

EINTR 

A signal interrupted the call.

EMSGSIZE 

Message size is too big to be sent atomically.

ENETDOWN 

The network subsystem has failed.

ENOBUFS 

No buffer space is available.

ENOTCONN 

The socket is not connected. (connection oriented sockets only.)

ENOTSOCK 

s is not a socket descriptor.

EOPNOTSUPP 

MSG_OOB was specified, but the socket is not stream style such as type SOCK_STREAM, out-of-band data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only receive operations.

ESHUTDOWN 

The socket has been shutdown; it is not possible to sendmsg() on a socket after shutdown() has been invoked with how set to SD_SEND or SD_BOTH.

ETIMEDOUT 

Connection has been dropped, because of a network failure or because the system on the other end went down without notice.

EWOULDBLOCK 

s is nonblocking and sendmsg() would block.


CONFORMANCE

UNIX 98, with exceptions.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

The sendmsg() function is only supported for sockets created with the AF_UNIX address family.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
bind(), connect(), getsockopt(), recv(), recvfrom(), recvmsg(), select(), send(), sendto(), setsockopt(), shutdown(), socket(), socketpair()


PTC MKS Toolkit 10.4 Documentation Build 39.