SYNOPSIS
#include <sys/socket.h>
int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
DESCRIPTION
The
For a SOCK_STREAM socket, as much information is returned
as is currently available, up to the size of the specified buffer.
If the socket has been configured for inline reception of out-of-band
data (socket option SO_OOBINLINE) and out-of-band data is unread,
only out-of-band data is returned.
The application may use the
For SOCK_DGRAM sockets, data is extracted from the
first queued message, up to the size of the specified buffer. If
the datagram or message is larger than the specified buffer, as
much data are stored in the buffer as possible and
If from is nonzero and the socket is not connection-oriented, the network address of the peer that sent the data is copied to the corresponding structure sockaddr. The value returned by fromlen is initialized to the size of this structure and is modified on return to indicate the actual size of the address stored there.
If the socket is connection-oriented
and the remote side has shut down the connection gracefully,
a
flags may be used to influence the behavior of the function invocation beyond the options specified for the associated socket. That is, the semantics of this function are determined by the socket options and the flags parameter. The latter is constructed by or-ing any of the following values:
- MSG_PEEK
-
Peek at the incoming data. The data is copied into the buffer but is not removed from the input queue.
- MSG_OOB
-
Process out-of-band data.
PARAMETERS
- s
-
Specifies a socket descriptor from which data should be received.
- buf
-
Specifies the buffer in which to place the message.
- len
-
Specifies the length of the buffer area.
- flags
-
Allows the caller to control the reception by peeking at incoming data (MSG_PEEK)or by sending or receiving out-of-band data (MSG_OOB).
- from
-
Specifies a socket address structure to record the address of the message sender.
- fromlen
-
Specifies the length of the sender's address.
RETURN VALUES
If successful,
- EBADF
-
s is an invalid descriptor
- ECONNABORTED
-
The virtual circuit was aborted because of a timeout or other failure.
- ECONNRESET
-
The virtual circuit was reset by the remote host executing a hard or abortive close.
- EFAULT
-
buf is an invalid pointer.
- EINTR
-
A signal interrupted the
recvfrom() call - EINVAL
-
Socket has not been bound using
bind() , or an invalid flag was specified, or len was 0 or negative. - EMSGSIZE
-
The message was too large to be stored in the specified buffer and was truncated.
- ENETDOWN
-
The network subsystem has failed.
- ENETRESET
-
The connection is broken; the remote host reset.
- ENOTCONN
-
The socket was not connected.
- ENOTSOCK
-
s is not a socket descriptor
- EOPNOTSUPP
-
MSG_OOB was specified on socket that does not support out of band data.
- ESHUTDOWN
-
The socket has been shut down.
- ETIMEDOUT
-
The connection has been dropped because of a network failure.
- EWOULDBLOCK
-
s is nonblocking and
recvfrom() would block
CONFORMANCE
UNIX 98, with exceptions.
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
The NuTCRACKER Platform supports all the address families that WinSock 2.0 supports.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Functions:
bind() ,connect() ,ioctl() ,read() ,recv() ,recvmsg() ,send() ,sendmsg() ,sendto() ,socket()
PTC MKS Toolkit 10.4 Documentation Build 39.