Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/sendto.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/sendto.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/sendto.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/sendto.html on line 8

sendto()

Send a message to a socket at a specific address

Synopsis:

#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 );

Arguments:

s
The descriptor for the socket; see socket().
msg
A pointer to the message that you want to send.
len
The length of the message.
flags
A combination of the following:
to
A pointer to a sockaddr object that specifies the address of the target.
tolen
A socklen_t object that specifies the size of the to address.

Library:

libsocket

Use the -l socket option to qcc to link against this library.

Description:

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.

Returns:

The number of bytes sent, or -1 if an error occurs (errno is set).

Errors:

EBADF
An invalid descriptor was specified.
EDESTADDRREQ
A destination address is required.
EFAULT
An invalid user space address was specified for a parameter.
EMSGSIZE
The socket requires that the message be sent atomically, but the size of the message made this impossible.
ENOBUFS
The system couldn't allocate an internal buffer. The operation may succeed when buffers become available.
ENOTSOCK
The argument s isn't a socket.
EWOULDBLOCK
The socket is marked nonblocking and the requested operation would block.

Classification:

POSIX 1003.1

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

getsockopt(), ioctl(), recv(), select(), send(), sendmsg(), socket(), write()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/sendto.html on line 229

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/sendto.html on line 229