BSD 3 development
[unix-history] / usr / man / man5 / mpxio.5
CommitLineData
b7ae4728
BJ
1.TH MPXIO 5
2.SH NAME
3mpxio \- multiplexed i/o
4.SH SYNOPSIS
5.B #include <sys/mx.h>
6.PP
7.B #include <sgtty.h>
8.SH DESCRIPTION
9Data transfers on
10mpx files
11(see
12.IR mpx (2))
13are multiplexed by
14imposing
15a record structure on the io stream.
16Each record represents data
17from/to
18a particular channel or
19a control or status message associated with a particular channel.
20.PP
21The prototypical data record read from an mpx file is as follows
22.PP
23.in +.5i
24.nf
25struct input_record {
26 short index;
27 short count;
28 short ccount;
29 char data[];
30};
31.PP
32.fi
33where
34.I index
35identifies the channel,
36and
37.I count
38specifies the number of characters in
39.I data.
40If
41.I count
42is zero,
43.I ccount
44gives the size of
45.I data,
46and the record is a control or status message.
47Although
48.I count
49or
50.I ccount
51might be odd,
52the operating system aligns records
53on short (i.e. 16\-bit) boundaries
54by skipping bytes when necessary.
55.PP
56Data written to an mpx file must be formatted as an array
57of record structures defined as follows
58.PP
59.in +.5i
60.nf
61struct output_record {
62 short index;
63 short count;
64 short ccount;
65 char *data;
66};
67.fi
68.PP
69where the data portion of the record is referred
70to indirectly and the other cells have the same interpretation
71as in
72.I input_record.
73.PP
74The
75control messages listed below may be read from
76a multiplexed file descriptor.
77They are presented as two 16-bit integers:
78the first number is the message code
79(defined in
80.IR <sys/mx.h> ),
81the second is an optional parameter meaningful
82only with M_WATCH, M_BLK, and M_SIG.
83.PP
84.in +1i
85.ti -.5i
86M_WATCH \- a process `wants to attach' on this channel.
87The second parameter is the 16-bit
88user-id of the process that executed the open.
89.br
90.ti -.5i
91M_CLOSE \- the channel is closed.
92This message is generated when the last
93file descriptor referencing
94a channel is closed.
95The
96.I detach
97command
98(see
99.IR mpx (2)
100should be used in response to this message.
101.br
102.ti -.5i
103M_EOT \- indicates logical end of file on a channel.
104If the channel is joined to a typewriter,
105EOT (control-d)
106will cause the M_EOT message
107under the conditions specified in
108.IR tty (4)
109for end of file.
110If the channel is attached to a process,
111M_EOT will be generated whenever the process
112writes zero bytes on the channel.
113.br
114.ti -.5i
115M_BLK \- if non-blocking mode has been enabled on an
116mpx file descriptor
117.I xd
118by executing
119.IR "ioctl(xd, MXNBLK, 0)" ,
120write operations on the file are truncated in the kernel
121when internal queues become full.
122This is done on a per-channel basis:
123the parameter
124is a count of the number of characters
125not transferred to the channel on which
126M_BLK is received.
127.br
128.ti -.5i
129M_UBLK \- is generated for a channel
130after M_BLK when the internal queues have
131drained below a threshold.
132.br
133.ti -.5i
134M_SIG \- is generated instead of a normal asynchronous
135signal on channels that are joined to typewriters.
136The parameter is the signal number.
137.in -1i
138.PP
139Two other messages may be generated by the kernel.
140As with other messages, the first
14116-bit quantity is the message code.
142.PP
143.in +1i
144.ti -.5i
145M_OPEN \- is generated in conjunction with
146`listener' mode (see
147.IR mpx (2)).
148The uid of the calling process follows the message code
149as with M_WATCH.
150This is followed by a null-terminated string
151which is the name of the file being opened.
152.br
153.ti -.5i
154M_IOCTL \- is generated for a channel connected
155to a process
156when that process executes the
157.I "ioctl(fd, cmd, &vec)"
158call on the channel file descriptor.
159The M_IOCTL code is followed by
160the
161.I cmd
162argument given to
163.I ioctl
164followed by
165the contents of the structure
166.I vec.
167It is assumed,
168not needing a better compromise at this time,
169that the length of
170.I vec
171is determined by
172.I "sizeof (struct sgttyb)"
173as declared in
174.IR <sgtty.h> .
175.in -1i
176.PP
177Two control messages are understood by the operating system.
178M_EOT may be sent through an mpx file to a channel.
179It is equivalent to propagating a zero-length record
180through the channel;
181i.e. the channel is allowed to drain and the process or
182device at the other end receives a zero-length
183transfer before data starts flowing through the channel again.
184M_IOCTL can also be sent through a channel.
185The format is identical to that described above.