Open System Services System Calls Reference Manual (G06.25+, H06.03+)

recvfrom(2) OSS System Calls Reference Manual
NAME
recvfrom - Receives a message from a socket
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/socket.h>
ssize_t recvfrom(
int socket,
void *buffer,
size_t length,
int ags,
struct sockaddr *address,
size_t *address_len
);
PARAMETERS
socket Species the le descriptor of the socket.
buffer Points to the buffer where the message should be written.
length Species the length in bytes of the buffer pointed to by the buffer parameter.
flags Is a value that controls message reception. The value of the ags parameter is
formed by bitwise ORing zero or more of the following values:
MSG_OOB Requests out-of-band data.
MSG_PEEK Peeks at an incoming message. The data is treated as unread and
the next call to the recvfrom() function (or similar function)
will still return this data.
address Species either a null pointer or a pointer to a sockaddr structure in which the
sending address is to be stored. The length and format of the address depend on
the address family of the socket.
For AF_INET sockets, a pointer to the address structure sockaddr_in must be
cast as a struct sockaddr.ForAF_INET6 sockets, a pointer to the address
structure sockaddr_in6 must be cast as a struct sockaddr.ForAF_UNIX sock-
ets, a pointer to the address structure sockaddr_un must be cast as a struct
sockaddr.
address_len Points to a size_t data item, which, on input, species the length of the sockaddr
structure that is pointed to by the address parameter, and, on return, species the
length of the address stored.
DESCRIPTION
The recvfrom() function receives messages from a connection-oriented or connectionless
socket. recvfrom() is normally used with connectionless sockets because it includes parameters
that permit a calling program to retrieve the source address of received data.
For message-based sockets (sockets of type SOCK_DGRAM), the entire message must be read
in one call. If a message is too long to t in the supplied buffer and MSG_PEEK is not set in the
ags parameter, the excess bytes are discarded.
For stream-based sockets (sockets of type SOCK_STREAM), message boundaries are ignored.
For such sockets, data is returned as soon as it becomes available; no data is discarded.
616 Hewlett-Packard Company 527186-003