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