PRIOMethods 编辑

The table of I/O methods used in a file descriptor.

Syntax

#include <prio.h>

struct PRIOMethods {
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRDescType file_type;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRCloseFN close;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRReadFN read;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRWriteFN write;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRAvailableFN available;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRAvailable64FN available64;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFsyncFN fsync;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRSeekFN seek;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRSeek64FN seek64;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileInfoFN fileInfo;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRFileInfo64FN fileInfo64;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRWritevFN writev;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRConnectFN connect;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRAcceptFN accept;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRBindFN bind;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRListenFN listen;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRShutdownFN shutdown;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRRecvFN recv;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRSendFN send;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRRecvfromFN recvfrom;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRSendtoFN sendto;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRPollFN poll;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRAcceptreadFN acceptread;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRTransmitfileFN transmitfile;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRGetsocknameFN getsockname;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRGetpeernameFN getpeername;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRGetsockoptFN getsockopt;
  /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/PRSetsockoptFN setsockopt;
};

typedef struct PRIOMethods PRIOMethods;

Parameters

file_type
Type of file represented (tos).
close
Close file and destroy descriptor.
read
Read up to the specified number of bytes into buffer.
write
Write specified number of bytes from buffer.
available
Determine number of bytes available for reading.
available64
Same as previous field, except 64-bit.
fsync
Flush all in-memory buffers of file to permanent store.
seek
Position the file pointer to the desired place.
seek64
Same as previous field, except 64-bit.
fileInfo
Get information about an open file.
fileInfo64
Same as previous field, except 64-bit.
writev
Write from a vector of buffers.
connect
Connect to the specified network address.
accept
Accept a connection from a network peer.
bind
Associate a network address with the file descriptor.
listen
Prepare to listen for network connections.
shutdown
Shut down a network connection.
recv
Receive up to the specified number of bytes.
send
Send all the bytes specified.
recvfrom
Receive up to the specified number of bytes and report network source.
sendto
Send bytes to specified network address.
poll
Test the file descriptor to see if it is ready for I/O.
acceptread
Accept and read from a new network file descriptor.
transmitfile
Transmit an entire file to the specified socket.
getsockname
Get network address associated with a file descriptor.
getpeername
Get peer's network address.
getsockopt
Get current setting of specified socket option.
setsockopt
Set 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 /wiki/en-US/docs/Mozilla/Projects/NSPR/Reference/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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:26 次

字数:8405

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文