![]() |
![]() |
![]() |
Send a message and its header to a socket
#include <sys/types.h> #include <sys/socket.h> int sendmsg( int s, const struct msghdr * msg, int flags );
libsocket
The sendmsg() function is used to transmit a message to another socket. The send() function can be used only when the socket is in a connected state, the sendmsg() function can be used at any time.
No indication of failure to deliver is implicit in a sendmsg(). Locally detected errors are indicated by a return value of -1.
If no message space is available at the socket to hold the message to be transmitted, then sendmsg() normally blocks, unless the socket has been placed in nonblocking I/O mode. The select() call may be used to determine when it's possible to send more data.
The flags parameter may include one or more of the following:
The flag MSG_OOB is used to send "out-of-band" data on sockets that support this notion (e.g. SOCK_STREAM). The underlying protocol must also support "out-of-band" data. MSG_DONTROUTE is normally used only by diagnostic or routing programs.
![]() |
MSG_OOB and MSG_DONTROUTE aren't supported by the tiny TCP/IP stack. For more information, see the npm-ttcpip.so interface in the Utilities reference. |
See recvmsg() for a description of the msghdr structure.
The number of bytes sent, or -1 if an error occurs (errno is set).
Standard Unix, POSIX 1003.1g (draft)
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
getsockopt(), ioctl(), recv(), select(), send(), sendto(), socket(), write()
![]() |
![]() |
![]() |