123 lines
8.0 KiB
HTML
123 lines
8.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>System Interfaces Chapter 2</title>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3">
|
|
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001</font></center>
|
|
|
|
<hr size="2" noshade>
|
|
<h3><a name="tag_02_06"></a>STREAMS</h3>
|
|
|
|
<p><sup>[<a href="javascript:open_code('XSR')">XSR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
STREAMS functionality is provided on implementations supporting the XSI STREAMS Option Group. This functionality is dependent on
|
|
support of the XSI STREAMS option (and the rest of this section is not further marked for this option). <img src=
|
|
"../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
|
|
<p>STREAMS provides a uniform mechanism for implementing networking services and other character-based I/O. The STREAMS function
|
|
provides direct access to protocol modules. STREAMS modules are unspecified objects. Access to STREAMS modules is provided by
|
|
interfaces in IEEE Std 1003.1-2001. Creation of STREAMS modules is outside the scope of
|
|
IEEE Std 1003.1-2001.</p>
|
|
|
|
<p>A STREAM is typically a full-duplex connection between a process and an open device or pseudo-device. However, since pipes may
|
|
be STREAMS-based, a STREAM can be a full-duplex connection between two processes. The STREAM itself exists entirely within the
|
|
implementation and provides a general character I/O function for processes. It optionally includes one or more intermediate
|
|
processing modules that are interposed between the process end of the STREAM (STREAM head) and a device driver at the end of the
|
|
STREAM (STREAM end).</p>
|
|
|
|
<p>STREAMS I/O is based on messages. There are three types of message:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p><i>Data messages</i> containing actual data for input or output</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p><i>Control data</i> containing instructions for the STREAMS modules and underlying implementation</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Other messages, which include file descriptors</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>The interface between the STREAM and the rest of the implementation is provided by a set of functions at the STREAM head. When a
|
|
process calls <a href="../functions/write.html"><i>write</i>()</a>, <a href="../functions/writev.html"><i>writev</i>()</a>, <a
|
|
href="../functions/putmsg.html"><i>putmsg</i>()</a>, <a href="../functions/putpmsg.html"><i>putpmsg</i>()</a>, or <a href=
|
|
"../functions/ioctl.html"><i>ioctl</i>()</a>, messages are sent down the STREAM, and <a href=
|
|
"../functions/read.html"><i>read</i>()</a>, <a href="../functions/readv.html"><i>readv</i>()</a>, <a href=
|
|
"../functions/getmsg.html"><i>getmsg</i>()</a>, or <a href="../functions/getpmsg.html"><i>getpmsg</i>()</a> accepts data from the
|
|
STREAM and passes it to a process. Data intended for the device at the downstream end of the STREAM is packaged into messages and
|
|
sent downstream, while data and signals from the device are composed into messages by the device driver and sent upstream to the
|
|
STREAM head.</p>
|
|
|
|
<p>When a STREAMS-based device is opened, a STREAM shall be created that contains the STREAM head and the STREAM end (driver). If
|
|
pipes are STREAMS-based in an implementation, when a pipe is created, two STREAMS shall be created, each containing a STREAM head.
|
|
Other modules are added to the STREAM using <a href="../functions/ioctl.html"><i>ioctl</i>()</a>. New modules are "pushed" onto
|
|
the STREAM one at a time in last-in, first-out (LIFO) style, as though the STREAM was a push-down stack.</p>
|
|
|
|
<h5><a name="tag_02_06_00_01"></a>Priority</h5>
|
|
|
|
<p>Message types are classified according to their queuing priority and may be <i>normal</i> (non-priority), <i>priority</i>, or
|
|
<i>high-priority</i> messages. A message belongs to a particular priority band that determines its ordering when placed on a queue.
|
|
Normal messages have a priority band of 0 and shall always be placed at the end of the queue following all other messages in the
|
|
queue. High-priority messages are always placed at the head of a queue, but shall be discarded if there is already a high-priority
|
|
message in the queue. Their priority band shall be ignored; they are high-priority by virtue of their type. Priority messages have
|
|
a priority band greater than 0. Priority messages are always placed after any messages of the same or higher priority.
|
|
High-priority and priority messages are used to send control and data information outside the normal flow of control. By
|
|
convention, high-priority messages shall not be affected by flow control. Normal and priority messages have separate flow
|
|
controls.</p>
|
|
|
|
<h5><a name="tag_02_06_00_02"></a>Message Parts</h5>
|
|
|
|
<p>A process may access STREAMS messages that contain a data part, control part, or both. The data part is that information which
|
|
is transmitted over the communication medium and the control information is used by the local STREAMS modules. The other types of
|
|
messages are used between modules and are not accessible to processes. Messages containing only a data part are accessible via <a
|
|
href="../functions/putmsg.html"><i>putmsg</i>()</a>, <a href="../functions/putpmsg.html"><i>putpmsg</i>()</a>, <a href=
|
|
"../functions/getmsg.html"><i>getmsg</i>()</a>, <a href="../functions/getpmsg.html"><i>getpmsg</i>()</a>, <a href=
|
|
"../functions/read.html"><i>read</i>()</a>, <a href="../functions/readv.html"><i>readv</i>()</a>, <a href=
|
|
"../functions/write.html"><i>write</i>()</a>, or <a href="../functions/writev.html"><i>writev</i>()</a>. Messages containing a
|
|
control part with or without a data part are accessible via calls to <a href="../functions/putmsg.html"><i>putmsg</i>()</a>, <a
|
|
href="../functions/putpmsg.html"><i>putpmsg</i>()</a>, <a href="../functions/getmsg.html"><i>getmsg</i>()</a>, or <a href=
|
|
"../functions/getpmsg.html"><i>getpmsg</i>()</a>.</p>
|
|
|
|
<h4><a name="tag_02_06_01"></a>Accessing STREAMS</h4>
|
|
|
|
<p>A process accesses STREAMS-based files using the standard functions <a href="../functions/close.html"><i>close</i>()</a>, <a
|
|
href="../functions/ioctl.html"><i>ioctl</i>()</a>, <a href="../functions/getmsg.html"><i>getmsg</i>()</a>, <a href=
|
|
"../functions/getpmsg.html"><i>getpmsg</i>()</a>, <a href="../functions/open.html"><i>open</i>()</a>, <a href=
|
|
"../functions/pipe.html"><i>pipe</i>()</a>, <a href="../functions/poll.html"><i>poll</i>()</a>, <a href=
|
|
"../functions/putmsg.html"><i>putmsg</i>()</a>, <a href="../functions/putpmsg.html"><i>putpmsg</i>()</a>, <a href=
|
|
"../functions/read.html"><i>read</i>()</a>, or <a href="../functions/write.html"><i>write</i>()</a>. Refer to the applicable
|
|
function definitions for general properties and errors.</p>
|
|
|
|
<p>Calls to <a href="../functions/ioctl.html"><i>ioctl</i>()</a> shall perform control functions on the STREAM associated with the
|
|
file descriptor <i>fildes</i>. The control functions may be performed by the STREAM head, a STREAMS module, or the STREAMS driver
|
|
for the STREAM.</p>
|
|
|
|
<p>STREAMS modules and drivers can detect errors, sending an error message to the STREAM head, thus causing subsequent functions to
|
|
fail and set <i>errno</i> to the value specified in the message. In addition, STREAMS modules and drivers can elect to fail a
|
|
particular <a href="../functions/ioctl.html"><i>ioctl</i>()</a> request alone by sending a negative acknowledgement message to the
|
|
STREAM head. This shall cause just the pending <a href="../functions/ioctl.html"><i>ioctl</i>()</a> request to fail and set
|
|
<i>errno</i> to the value specified in the message.</p>
|
|
|
|
<hr size="2" noshade>
|
|
<center><font size="2">UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
</font> [ <a href="../mindex.html">Main Index</a>]</center>
|
|
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|