blob: 127c64f543404dd253a0a33e3aa279c8b22b3b84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
PRIOMethods
===========
The table of I/O methods used in a file descriptor.
Syntax
------
.. code::
#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_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 :ref:`PRIOMethods`
implements the :ref:`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``.
|