Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ read(2dn) — Ultrix DECnet 3.0 VAX

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

socket(2dn)

dnet_eof(3dn)

pipe(2)

socketpair(2)

read(2dn)

NAME

read − read or receive data

SYNTAX

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

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

ARGUMENTS

Input Arguments

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

buf Specifies the address of buffer into which data is read. 

buflen Specifies the size of the message buffer. 

Return Arguments

cc Length of the returned message. 

DESCRIPTION

The read call is used to read normal data messages from another DECnet program.  You can use read only on a connected socket. See the connect call for more information.  If no messages are available at the socket, the read 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.

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 read call.

RETURN VALUE

If the call succeeds, the number of bytes actually read and placed in the buffer are returned.  The system guarantees to read the number of bytes requested only if the descriptor references a file containing that many bytes before the end of file.  If the end of file has been reached, a value of 0 is returned. 

A returned value of 0 can also indicate that a zero-length message has been received on a sequenced packet socket.  For further information, see dnet_eof.

If an error occurs, a value of −1 is returned and the global variable errno is set to indicate the error.

DIAGNOSTICS

[EBADF] The s argument is not a valid file descriptor open for reading. 

[EFAULT] The buf argument points outside the allocated address space. 

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

[EINTR] A read from a slow device was interrupted  by the delivery of a signal before any data arrived.

SEE ALSO

socket(2dn), dnet_eof(3dn)

ULTRIX-32 Programmer’s Manual: dup(2), pipe(2), socketpair(2)

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