PRIOMethods
The table of I/O methods used in a file descriptor.
Syntax
#include <prio.h>
struct PRIOMethods {
PRDescType file_type;
PRCloseFN close;
PRReadFN read;
PRWriteFN write;
PRAvailableFN available;
PRAvailable64FN available64;
PRFsyncFN fsync;
PRSeekFN seek;
PRSeek64FN seek64;
PRFileInfoFN fileInfo;
PRFileInfo64FN fileInfo64;
PRWritevFN writev;
PRConnectFN connect;
PRAcceptFN accept;
PRBindFN bind;
PRListenFN listen;
PRShutdownFN shutdown;
PRRecvFN recv;
PRSendFN send;
PRRecvfromFN recvfrom;
PRSendtoFN sendto;
PRPollFN poll;
PRAcceptreadFN acceptread;
PRTransmitfileFN transmitfile;
PRGetsocknameFN getsockname;
PRGetpeernameFN getpeername;
PRGetsockoptFN getsockopt;
PRSetsockoptFN setsockopt;
};
typedef struct PRIOMethods PRIOMethods;
Parameters
file_typeType of file represented (tos).
closeClose file and destroy descriptor.
readRead up to the specified number of bytes into buffer.
writeWrite specified number of bytes from buffer.
availableDetermine number of bytes available for reading.
available64Same as previous field, except 64-bit.
fsyncFlush all in-memory buffers of file to permanent store.
seekPosition the file pointer to the desired place.
seek64Same as previous field, except 64-bit.
fileInfoGet information about an open file.
fileInfo64Same as previous field, except 64-bit.
writevWrite from a vector of buffers.
connectConnect to the specified network address.
acceptAccept a connection from a network peer.
bindAssociate a network address with the file descriptor.
listenPrepare to listen for network connections.
shutdownShut down a network connection.
recvReceive up to the specified number of bytes.
sendSend all the bytes specified.
recvfromReceive up to the specified number of bytes and report network source.
sendtoSend bytes to specified network address.
pollTest the file descriptor to see if it is ready for I/O.
acceptreadAccept and read from a new network file descriptor.
transmitfileTransmit an entire file to the specified socket.
getsocknameGet network address associated with a file descriptor.
getpeernameGet peer’s network address.
getsockoptGet current setting of specified socket option.
setsockoptSet value of specified socket option.
Description
You don’t need to know the type declaration for each function listed in
the method table unless you are implementing a layer. For information
about each function, see the corresponding function description in this
document. For example, the write method in PRIOMethods
implements the PR_Write function. For type definition details, see
prio.h.
The I/O methods table provides procedural access to the functions of the
file descriptor. It is the responsibility of a layer implementer to
provide suitable functions at every entry point (that is, for every
function in the I/O methods table). If a layer provides no
functionality, it should call the next lower (higher) function of the
same name (for example, the “close” method would return
fd->lower->method->close(fd->lower)).
Not all functions in the methods table are implemented for all types of
files. For example, the seek method is implemented for normal files but
not for sockets. In cases where this partial implementation occurs, the
function returns an error indication with an error code of
PR_INVALID_METHOD_ERROR.