Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ recv(2dn) — Ultrix DECnet 3.0 VAX

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

read(2dn)

send(2dn)

setsockopt(2dn)

socket(2dn)

write(2dn)

recv(2dn)

NAME

recv − receive normal data and out-of-band messages

SYNTAX

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

cc = recv (s,buf,buflen,flags)
int cc,s;
char *buf;
int buflen,flags;

ARGUMENTS

Input Arguments

s Specifies a descriptor for a socket that has been returned by the socket call.

buf Specifies the address of the buffer that will contain the received message. 

buflen Specifies the size of the message buffer. 

flags Set to MSG_PEEK, which looks at incoming messages, or to MSG_OOB, which indicates that a program will receive out-of-band messages. 

Return Arguments

cc Length of the returned message. 

DESCRIPTION

The recv call is used to receive out-of-band data from another DECnet program. The recv call can be used only on a connected socket. For further information, see the connect call. If no messages are available at a socket, the recv call waits for a message to arrive.  However, if the socket is nonblocking, a status of -1 is returned with the external variable errno set to EWOULDBLOCK.

Use the recv call instead of the read call when you want to specify the MSG_PEEK and MSG_OOB flags arguments to look at incoming messages and to receive out-of-band messages. 

You can use the select call to determine when more data will arrive.

The length of the message is returned in cc.  If a message is too long to fit in the supplied buffer, the excess bytes can be discarded depending on the type of socket from which the message is received.  Sequenced packet sockets discard extra bytes.  Stream sockets store extra bytes in the kernel and use them for the next recv call.

The flags argument for a recv call is formed by or’ing one or more of the following values:

#defineMSG_PEEK   0x1   /* peek at incoming message */
#defineMSG_OOB    0x2   /* process out-of-band data */

Out-of-band messages are sent to a receiving program ahead of normal data messages.  Out-of-band messages are sent and received as DECnet interrupt messages and can be from 1- to 16-bytes in length. See setsockopt(2dn) for more information.  The signal SIGURG indicates the arrival of out-of-band data. 

RETURN VALUE

If the call succeeds, the number of received characters is returned.  If an error occurs, a value of −1 is returned. Additional error details.  will be specified in the external variable errno.

DIAGNOSTICS

[EBADF] The s argument is not a valid descriptor. 

[EWOULDBLOCK] The socket is marked nonblocking and the receive operation would have blocked.

[EFAULT] The data was specified to be received into a nonexistent or protected part of the process address space. 

RESTRICTIONS

The MSG_PEEK flags arguments cannot be used with out-of band messages. 

SEE ALSO

read(2dn), send(2dn), setsockopt(2dn), socket(2dn), write(2dn)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026