⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsh_chap02_06.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 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-2003 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 onsupport 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 functionprovides direct access to protocol modules. STREAMS modules are unspecified objects. Access to STREAMS modules is provided byinterfaces in IEEE&nbsp;Std&nbsp;1003.1-2001. Creation of STREAMS modules is outside the scope ofIEEE&nbsp;Std&nbsp;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 maybe STREAMS-based, a STREAM can be a full-duplex connection between two processes. The STREAM itself exists entirely within theimplementation and provides a general character I/O function for processes. It optionally includes one or more intermediateprocessing modules that are interposed between the process end of the STREAM (STREAM head) and a device driver at the end of theSTREAM (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 aprocess calls <a href="../functions/write.html"><i>write</i>()</a>, <a href="../functions/writev.html"><i>writev</i>()</a>, <ahref="../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 theSTREAM and passes it to a process. Data intended for the device at the downstream end of the STREAM is packaged into messages andsent downstream, while data and signals from the device are composed into messages by the device driver and sent upstream to theSTREAM 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). Ifpipes 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 &quot;pushed&quot; ontothe 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 thequeue. High-priority messages are always placed at the head of a queue, but shall be discarded if there is already a high-prioritymessage in the queue. Their priority band shall be ignored; they are high-priority by virtue of their type. Priority messages havea 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. Byconvention, high-priority messages shall not be affected by flow control. Normal and priority messages have separate flowcontrols.</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 whichis transmitted over the communication medium and the control information is used by the local STREAMS modules. The other types ofmessages are used between modules and are not accessible to processes. Messages containing only a data part are accessible via <ahref="../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 acontrol part with or without a data part are accessible via calls to <a href="../functions/putmsg.html"><i>putmsg</i>()</a>, <ahref="../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>, <ahref="../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 applicablefunction 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 thefile descriptor <i>fildes</i>. The control functions may be performed by the STREAM head, a STREAMS module, or the STREAMS driverfor the STREAM.</p><p>STREAMS modules and drivers can detect errors, sending an error message to the STREAM head, thus causing subsequent functions tofail and set <i>errno</i> to the value specified in the message. In addition, STREAMS modules and drivers can elect to fail aparticular <a href="../functions/ioctl.html"><i>ioctl</i>()</a> request alone by sending a negative acknowledgement message to theSTREAM 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"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -