This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Send a message to a socket at a specific address
#include <sys/types.h> #include <sys/socket.h> ssize_t sendto( int s, const void * msg, size_t len, int flags, const struct sockaddr * to, socklen_t tolen );
The tiny TCP/IP stack doesn't support MSG_OOB and MSG_DONTROUTE. For more information, see npm-ttcpip.so in the Utilities Reference. |
libsocket
Use the -l socket option to qcc to link against this library.
The sendto() function is used to transmit a message to another socket. You can use send() only when the socket is in a connected state; you can use sendto() at any time.
The address of the target is given by to, with tolen specifying its size. The length of the message is given by len. If the message is too long to pass atomically through the underlying protocol, the error EMSGSIZE is returned, and the message isn't transmitted.
No indication of failure to deliver is implicit in a sendto(). 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 sendto() normally blocks, unless the socket has been placed in nonblocking I/O mode. You can use select() to determine when it's possible to send more data.
The number of bytes sent, or -1 if an error occurs (errno is set).
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
getsockopt(), ioctl(), recv(), select(), send(), sendmsg(), socket(), write()