SYNOPSIS
#include <sys/socket.h>
int recv(int s, void *buf, size_t len, int flags);
DESCRIPTION
The
A
For SOCK_DGRAM sockets, data is extracted from the
first queued datagram for the destination address specified in
the connect call. If unconnected, the socket must be bound and
have no source address restrictions on the datagrams received. If
the datagram is larger than the buffer supplied, the buffer is
filled with the first part of the datagram and
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
-
Points to the buffer in which to place the message.
- len
-
Specifies the length of the buffer.
- flags
-
Lets the caller control the reception by peeking at incoming data (MSG_PEEK) or receive out-of-band data (MSG_OOB).
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
recv() call. - EINVAL
-
The socket was not bound using
bind() , or an invalid flag was specified, or len was 0 or negative. - EMSGSIZE
-
The message was too large to fit the specified buffer.
- ENETDOWN
-
The network subsystem has failed.
- ENETRESET
-
The connection is broken; the remote host reset.
- ENOTCONN
-
The socket is 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
recv() would block.
CONFORMANCE
UNIX 98, with exceptions.
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
The
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() ,recvfrom() ,recvmsg() ,send() ,sendmsg() ,sendto() ,socket() ,socketpair()
PTC MKS Toolkit 10.5 Documentation Build 40.