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/r/recvfrom.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/r/recvfrom.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/r/recvfrom.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/r/recvfrom.html on line 8

recvfrom()

Receive a message from the socket at a specified address

Synopsis:

#include <sys/types.h>
#include <sys/socket.h>

ssize_t recvfrom( int s,
                  void * buff,
                  size_t len,
                  int flags,
                  struct sockaddr * from,
                  socklen_t * fromlen );

Arguments:

s
The descriptor for the socket; see socket().
buf
A pointer to a buffer where the function can store the message.
len
The size of the buffer.
flags
A combination formed by ORing one or more of the values:
from
NULL, or a pointer to a sockaddr object where the function can store the source address of the message.
fromlen
A pointer to a socklen_t object that specifies the size of the from buffer. The function stores the actual size of the address in this object.

Library:

libsocket

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

Description:

The recvfrom() routine receives a message from the socket, s, whether or not it's connection-oriented.

If from is nonzero, and the socket is connectionless, the source address of the message is filled in. The parameter fromlen is a value-result parameter, initialized to the size of the buffer associated with from, and modified on return to indicate the actual size of the stored address.

This routine returns the length of the message on successful completion. If a message is too long for the supplied buffer, buf, excess bytes may be discarded depending on the type of socket that the message is received from—see socket().

If no messages are available at the socket, the receive call waits for a message to arrive, unless the socket is nonblocking—see ioctl()—in which case recvfrom() returns -1 is returned and sets the external variable errno to EWOULDBLOCK. Normally, the receive calls return any data available, up to the requested amount, rather than wait for the full amount requested; this behavior is affected by the socket-level options SO_RCVLOWAT and SO_RCVTIMEO described in getsockopt().

You can use select() to determine when more data is to arrive.

Returns:

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

Errors:

EBADF
Invalid descriptor s.
EFAULT
The receive buffer pointer(s) point outside the process's address space.
EINTR
The receive was interrupted by delivery of a signal before any data was available.
ENOTCONN
The socket is associated with a connection-oriented protocol and hasn't been connected; see connect() and accept().
EWOULDBLOCK
Either the socket is marked nonblocking and the receive operation would block, or a receive timeout had been set and the timeout expired before data was received.

Classification:

POSIX 1003.1

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

See also:

recv(), recvmsg(), select()


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/r/recvfrom.html on line 242

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/r/recvfrom.html on line 242