The table of I/O methods used in a file descriptor.
#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;
file_type
close
read
write
available
available64
fsync
seek
seek64
fileInfo
fileInfo64
writev
connect
accept
bind
listen
shutdown
recv
send
recvfrom
sendto
poll
acceptread
transmitfile
getsockname
getpeername
getsockopt
setsockopt
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 implementor 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
.