VMS Help
TCPIP Services, Programming Interfaces, Sockets API, recv()
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
Receives bytes from a connected socket and places them into a
user-provided buffer.
The $QIO equivalent is the IO$_READVBLK function.
Format
#include <types.h>
#include <socket.h>
int recv ( int s, char *buf, int len, int flags );
s
A socket descriptor created as the result of a call to accept()
or connect().
buf
A pointer to a user-provided buffer into which received data will
be placed.
len
The size of the buffer pointed to by buf.
flags
A bit mask that can contain one or more of the following
flags. The mask is built by using a logical OR operation on the
appropriate values.
Flag Description
MSG_OOB Allows you to receive out-of-band data.
If out-of-band data is available, it is read
first. If no out-of-band data is available,
the MSG_OOB flag is ignored.
Use the send(), sendmsg(), and sendto()
functions to send out-of-band data.
MSG_PEEK Allows you to examine data in the receive
buffer without removing it from the system's
buffers.
This function receives data from a connected socket. To receive
data on an unconnected socket, use the recvfrom() or recvmsg()
functions. The received data is placed in the buffer buf.
Data is sent by the socket's peer using the send, sendmsg(),
sendto(), or write() functions.
Use the select() function to determine when more data arrives.
If no data is available at the socket, the receive call waits for
data to arrive, unless the socket is nonblocking. If the socket
is nonblocking, a -1 is returned with the external variable errno
set to EWOULDBLOCK.
Related Functions
See also read(), send(), sendmsg(), sendto(), and socket().
x The number of bytes received and placed in
buf.
0 Peer has closed its send side of the
connection.
-1 Error; errno is set to indicate the error.
EBADF The socket descriptor is invalid.
ECONNRESET A connection was forcibly closed by a peer.
EFAULT The data was specified to be received into a
nonexistent or protected part of the process
address space.
EINTR A signal interrupted the recv() function
before any data was available.
EINVAL The MSG_OOB flag is set and no out-of-band
data is available.
ENOBUFS The system has insufficient resources to
complete the call.
ENOMEM The system did not have sufficient memory to
fulfill the request.
ENOTCONN A receive is attempted on a connection-
oriented socket that is not connected.
ENOTSOCK The socket descriptor is invalid.
EOPNOTSUPP The specified flags are not supported for this
socket type or protocol.
EWOULDBLOCK The socket is marked nonblocking, and no data
is waiting to be received.
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.