📄 streams.doc7.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="../../wrs.css"><title>WindNet STREAMS Components WindNet STREAMS for Tornado </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="../../icons/contents.gif"></a><a href="streams.doc6.html"><img border="0" alt="[Prev]" src="../../icons/prev.gif"></a><a href="streams.doc8.html"><img border="0" alt="[Next]" src="../../icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="80040" class="autotag">3.1 XTI/TLI Programming</a></i></h3></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="75828" class="autotag"> </a>The X/Open Transport Interface (XTI) and Transport Level Interface (TLI) define an independent transport service interface that allows multiple applications to communicate at the transport level of the transport provider. XTI is a newer and enhanced superset of TLI. (In this supplement, the two interfaces are generally referred to together, XTI/TLI, since the discussion applies to both.) XTI/TLI provides generalized routines that support network communications involving many possible transport protocols. XTI/TLI routines provide an interface between an application program and the protocol software, as shown in <a href="streams.doc7.html#75833"><i class="title">Figure 2</i></a>. <div class="frame"><h4 class="EntityTitle"><a name="75833" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 2. Composition of XTI/TLI</font></a></h4><div class="CellBody"><a name="75831" class="autotag"> </a><img class="figure" border="0" alt="" src="images/streams.doc.anc14.gif"></div></div></p><p class="Body"><a name="94680" class="autotag"> </a>XTI and TLI are implemented as interfaces to the STREAMS transport provider protocol. They are media- and protocol-independent, and allow applications to run over any transport provider that complies with the Transport Provider Interface standard published in the <i class="title">Transport Provider Interface Specification</i> (UNIX International). The XTI and TLI specifications describe transport characteristics supported by a wide range of transport-layer protocols.</p><p class="Body"><a name="94681" class="autotag"> </a>The functionality provided by the transport provider includes:</p></dd></dl><dl class="margin"><dd><p class="listspace"><ul class="Bullet" type="disc"><li><a name="94682" class="autotag"> </a>Connection establishment.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="75837" class="autotag"> </a>State change support.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="75838" class="autotag"> </a>Event handling.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="75839" class="autotag"> </a>Data transfer.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="75840" class="autotag"> </a>Options manipulation.</li></ul></p></dd></dl><dl class="margin"><dd><p class="Body"><a name="75841" class="autotag"> </a>All transport protocols support these characteristics. </p><p class="Body"><a name="83100" class="autotag"> </a>XTI and TLI provide transport users considerable independence from the underlying transport provider. For example, XTI/TLI applications written for the TCP transport protocol can be easily adapted to work over the OSI transport protocol. XTI and TLI help transport users interact with different transport providers as if there were only small differences between providers, for instance, their protocol addresses. </p><p class="Body"><a name="75843" class="autotag"> </a>For a list of the differences between XTI and TLI, see <a href="streams.doc7.html#80170"><i class="title">§3.1.8 Examining the Relationship Between XTI and TLI</i></a>.</p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="75846" class="autotag">3.1.1 Transport Endpoints</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="75847" class="autotag"> </a>A transport endpoint specifies a communication path between a transport user and a transport provider, as shown in <a href="streams.doc7.html#75852"><i class="title">Figure 3</i></a>. When a user opens a transport provider by invoking <b class="routine"><i class="routine">t_open</i></b><b>( )</b>, a file descriptor is returned that identifies the transport endpoint. A transport provider is the transport protocol that provides the services of the transport layer. All requests to the transport provider must pass through the transport endpoint. To be active, a transport endpoint must have a transport address associated with it. This association is established by the <b class="routine"><i class="routine">t_bind</i></b><b>( )</b> call. A transport connection is established by routines that create an association between two active endpoints. <div class="frame"><h4 class="EntityTitle"><a name="75852" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 3. Channel Between Transport User and Transport Provider</font></a></h4><div class="CellBody"><a name="75850" class="autotag"> </a><img class="figure" border="0" alt="" src="images/streams.doc.anc2.gif"></div></div> </p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="75853" class="autotag">3.1.2 Transport Providers</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="75854" class="autotag"> </a>The transport provider is a protocol module that provides transport services. It implements the transport-level protocol used for communication. Multiple transport protocols can co-exist in the STREAMS environment and function simultaneously. The identifier parameter of the transport provider passed to <b class="routine"><i class="routine">t_open</i></b><b>( )</b> determines the required transport provider. Applications that manage multiple transport providers must call <b class="routine"><i class="routine">t_open</i></b><b>( )</b> for each provider and listen for connect indications on each of the associated file descriptors. </p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="75860" class="autotag">3.1.3 Transport User</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="75861" class="autotag"> </a>The transport user is an application program that accesses the services of the transport provider by issuing the appropriate service requests, as illustrated in <a href="streams.doc7.html#78763"><i class="title">Figure 4</i></a>. One example of a transport user operation is a request to transfer data over a connection. Consequently, the transport provider notifies the user of various events in response to requests, such as the arrival of data on a connection. <div class="frame"><h4 class="EntityTitle"><a name="78763" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4. Transport Interface</font></a></h4><div class="CellBody"><a name="78760" class="autotag"> </a><img class="figure" border="0" alt="" src="images/streams.doc.anc4.gif"></div></div></p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="75867" class="autotag">3.1.4 Transport Connection Establishment</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="75868" class="autotag"> </a>The connection establishment phase enables two transport users to create a connection between them, as illustrated in <a href="streams.doc7.html#75873"><i class="title">Figure 5</i></a>.<div class="frame"><h4 class="EntityTitle"><a name="75873" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 5. Transport Connection</font></a></h4><div class="CellBody"><a name="75871" class="autotag"> </a><img class="figure" border="0" alt="" src="images/streams.doc.anc3.gif"></div></div></p><p class="Body"><a name="91224" class="autotag"> </a>An example of the connection establishment phase is a client-server relationship between two transport users. The server typically advertises some service to a group of users and then listens for requests for its service. As clients require the service, they attempt to connect temselves to the server using the server's advertised transport address. The <b class="routine"><i class="routine">t_connect</i></b><b>( )</b> routine initiates the connect request. One argument to <b class="routine"><i class="routine">t_connect</i></b><b>( )</b> is the transport address which identifies the server the client wishes to access. The server is notified of each incoming request while waiting in the <b class="routine"><i class="routine">t_listen</i></b><b>( )</b> routine. The server then can call <b class="routine"><i class="routine">t_accept</i></b><b>( )</b> to accept the connection or can invoke <b class="routine"><i class="routine">t_snndis</i></b><b>( )</b>to reject the request. If the request is accepted, the transport connection is established. If it is rejected, <b class="routine"><i class="routine">t_snddis</i></b><b>( )</b> notifies the client of rejection. For more information about client-server programming, see <a href="streams.doc7.html#79117"><i class="title">§3.1.11 XTI Client-Server Applications</i></a>.</p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="75876" class="autotag">3.1.5 Transport Provider Interface (TPI)</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="75877" class="autotag"> </a>The Transport Provider Interface (TPI) is a STREAMS service interface designed to implement the OSI transport layer service interface. A user communicates to a transport provider using a full duplex path known as a stream, as shown in <a href="streams.doc7.html#75882"><i class="title">Figure 6</i></a>. This stream provides a mechanism in which messages can be passed to the transport provider from the transport user, and vice versa. The XTI/TLI library works in close co-operation with timod, a STREAMS module that serves as a medium for TPI primitives passing from this library to the transport provider. <div class="frame"><h4 class="EntityTitle"><a name="75882" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 6. Example: Stream from a User to a Transport Provider</font></a></h4><div class="CellBody"><a name="75880" class="autotag"> </a><img class="figure" border="0" alt="" src="images/streams.doc.anc5.gif"></div></div> </p><p class="Body"><a name="75883" class="autotag"> </a>There are four kinds of primitives defined by the TPI: </p></dd></dl><dl class="margin"><dd><p class="listspace"><ul class="Bullet" type="disc"><li><a name="78786" class="autotag"> </a>Local management primitives</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="78787" class="autotag"> </a>Connection-establishment primitives</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="78788" class="autotag"> </a>Data-transfer primitives</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="78789" class="autotag"> </a>Connection-release primitives. </li></ul></p></dd></dl><dl class="margin"><dd><p class="Body"><a name="78790" class="autotag"> </a>The primitives are implemented as <b>M_PROTO</b> and <b>M_PCPROTO</b> STREAMS messages with the first four bytes in the data buffer indicating the primitive.</p><p class="Body"><a name="75885" class="autotag"> </a>XTI and TLI are implemented using TPI primitives. The XTI/TLI library routines map to specific TPI primitives. For example, <b class="routine"><i class="routine">t_bind</i></b><b>( )</b> translates to a TPI message primitive <b>T_BIND_REQ</b>, and expects a <b>T_BIND_ACK</b> as a response. The <b class="routine"><i class="routine">t_connect</i></b><b>( )</b> routine translates to a TPI primitive <b>T_CONN_REQ</b>.</p><p class="Body"><a name="75892" class="autotag"> </a><a href="streams.doc7.html#78905"><i class="title">Figure 7</i></a> shows an application making a <b class="routine"><i class="routine">t_connect</i></b><b>( )</b> request. It shows the primitives involved in the establishment of connection. The client transport user sends a connect request to the transport provider by using the <b>T_CONN_REQ</b> primitive. If the transport provider encounters an error, it sends a <b>T_ERROR_ACK</b> primitive to the client program, otherwise it responds to the transport user with a <b>T_OK_ACK</b>. <div class="frame"><h4 class="EntityTitle"><a name="78905" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 7. Primitives Used in Connection Setup</font></a></h4><div class="CellBody"><a name="78902" class="autotag"> </a><img class="figure" border="0" alt="" src="images/streams.doc.anc15.gif"></div></div></p><p class="Body"><a name="75894" class="autotag"> </a>At the server end, the client's connect request is delivered to the transport user as a <b>T_CONN_IND</b> primitive. If the server wishes to accept the connection request, it sends a <b>T_CONN_RES</b> primitive to the transport provider. This message is then sent to the client transport provider, which sends a connect confirmation, <b>T_CONN_CON</b>, to the client program. </p><p class="Body"><a name="75896" class="autotag"> </a>For a complete description of the STREAMS-based Transport Provider Interface, see <i class="title">STREAMS Modules and Drivers: UNIX SVR4.2</i> (UNIX Press) and <i class="title">Unix System V Network Programming</i>, by Stephen Rago (Addison-Wesley).</p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="75899" class="autotag">3.1.6 WindNet STREAMS XTI/TLI Library Routines</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="78938" class="autotag"> </a>WindNet STREAMS provides an XTI/TLI library containing the XTI-compatible and TLI-compatible routines listed in <a href="streams.doc7.html#86455"><i class="title">Table 1</i></a>. Configure the library into VxWorks by defining <b>INCLUDE_STREAMS_TLI</b> in <b class="file">configAll.h</b>. For information about configuring WindNet STREAMS, see <a href="streams.doc26.html#72453"><i class="title">§6.2 WindNet STREAMS Configuration</i></a>. For more specific information about these routines, see the <i class="title">UNIX System V Release 4 Programmer's Guide: Networking Interfaces</i>. <p class="table"><h4 class="EntityTitle"><a name="86455" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 1. WindNet STREAMS XTI/TLI Routines</font></a></h4><table border="0" cellpadding="3" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86459" class="autotag"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Routine</font></b></div></th><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86461" class="autotag"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"></th><th rowspan="1" colspan="1"></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86467" class="autotag"> </a><b class="routine"><i class="routine">t_accept</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86469" class="autotag"> </a>Accept a connection on a endpoint.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86471" class="autotag"> </a><b class="routine"><i class="routine">t_alloc</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86473" class="autotag"> </a>Allocate a library structure.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86475" class="autotag"> </a><b class="routine"><i class="routine">t_bind</i></b><b>( )</b></div></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -