📄 streams.doc8.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.doc7.html"><img border="0" alt="[Prev]" src="../../icons/prev.gif"></a><a href="streams.doc9.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="76298" class="autotag">3.2 STREAMS Sockets Programming</a></i></h3></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="76299" class="autotag"> </a>In VxWorks, STREAMS sockets serve as one interface to the STREAMS protocol suites. Sockets are designed to provide a consistent communication facility for tasks, regardless of whether or not the tasks are on the same machine. In addition, sockets are designed to hide as much detail as possible regarding the way in which the underlying communication occurs. </p><p class="Body"><a name="90467" class="autotag"> </a>A socket is an endpoint for communication that gets bound to a port within the node. Each socket in use has a type and is associated with a communication domain when it is created. Domains are abstractions that imply both an addressing structure and a set of protocols that implement socket types within the domain. </p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="76307" class="autotag">3.2.1 Socket Architecture in VxWorks</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="76308" class="autotag"> </a><a href="streams.doc8.html#79179"><i class="title">Figure 8</i></a> shows the architecture for socket communication in a VxWorks environment. Applications make calls that are handled by the socket layer. The socket layer translates a file descriptor to a socket and invokes a routine in the protocol layer to service the call. The socket data structure is shared between the socket layer and protocol layer. The protocol layer communicates with the network driver to send and receive packets to or from the network. <b><div class="frame"><h4 class="EntityTitle"><a name="79179" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 8. Socket Architecture in VxWorks</font></a></h4><div class="CellBody"><a name="79176" class="autotag"> </a><img class="figure" border="0" alt="" src="images/streams.doc.anc1.gif"></div></div></b></p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="76310" class="autotag">3.2.2 Socket Architecture in WindNet STREAMS</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="76311" class="autotag"> </a>The socket mechanism is implemented in the STREAMS framework, as shown in <a href="streams.doc8.html#76316"><i class="title">Figure 9</i></a>. A user-level library (configured by defining <b>INCLUDE_STREAMS_SOCKET</b> in <b class="file">configAll.h</b>; see <a href="streams.doc25.html#72373"><i class="title">§6.1 Configuring VxWorks for WindNet STREAMS</i></a>) provides socket calls, such as <b class="routine"><i class="routine">socket</i></b><b>( )</b>, <b class="routine"><i class="routine">connect</i></b><b>( )</b> , <b class="routine"><i class="routine">bind</i></b><b>( )</b>, etc. These library routines interact with a STREAMS module, <b>sockmod</b>, that is pushed on top of a STREAMS-based transport provider. The socket library and <b>sockmod</b> work in close cooperation. When semantics allow, the socket library creates TPI messages equivalent to <b class="routine"><i class="routine">socket</i></b><b>( )</b>, and <b>sockmod</b> passes the message to the transport provider. For other calls, the socket library does almost nothing except issue an <b class="routine"><i class="routine">ioctl</i></b><b>( )</b> that is intercepted by <b>sockmod</b>, which in turn creates a TPI message and interacts with the transport provider to complete the request. <a href="streams.doc8.html#77304"><i class="title">§3.2.4 Addition of Transport Providers to WindNet STREAMS Sockets</i></a> explains how this implementation has the undesirable effect of making it difficult to provide transport independence at the socket layer. <div class="frame"><h4 class="EntityTitle"><a name="76316" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 9. Socket Architecture in STREAMS</font></a></h4><div class="CellBody"><a name="76314" class="autotag"> </a><img class="figure" border="0" alt="" src="images/streams.doc.anc8.gif"></div></div></p></dd></dl></dd></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="76318" class="autotag">3.2.3 WindNet STREAMS Socket Library</a></i></h4></font><dl class="margin"><dd><dl class="margin"><dd><p class="Body"><a name="85524" class="autotag"> </a>The WindNet STREAMS socket library is provided to enable porting of existing socket applications to a STREAMS environment by relinking object code with the library. No source code changes should be required. <a href="streams.doc8.html#85531"><i class="title">Table 2</i></a> lists the basic socket routines found in the WindNet STREAMS socket library.<p class="table"><h4 class="EntityTitle"><a name="85531" class="autotag"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 2. WindNet STREAMS Socket 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="85535" 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="85537" 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="85973" class="autotag"> </a><b class="routine"><i class="routine">socket</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85975" class="autotag"> </a>Create a socket.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85977" class="autotag"> </a><b class="routine"><i class="routine">bind</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85979" class="autotag"> </a>Bind a name to a socket.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85981" class="autotag"> </a><b class="routine"><i class="routine">listen</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85983" class="autotag"> </a>Enable connections to a STREAMS socket. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85985" class="autotag"> </a><b class="routine"><i class="routine">accept</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85987" class="autotag"> </a>Accept a connection on a STREAMS socket.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85989" class="autotag"> </a><b class="routine"><i class="routine">connect</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85991" class="autotag"> </a>Initiate a connection on a socket.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85993" class="autotag"> </a><b class="routine"><i class="routine">shutdown</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85995" class="autotag"> </a>Shutdown a socket connection.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85997" class="autotag"> </a><b class="routine"><i class="routine">send</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85999" class="autotag"> </a>Send data to a STREAMS socket.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86001" class="autotag"> </a><b class="routine"><i class="routine">sendto</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86003" class="autotag"> </a>Send a message to a datagram socket.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86005" class="autotag"> </a><b class="routine"><i class="routine">sendmsg</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86007" class="autotag"> </a>Send a message to a datagram socket.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86009" class="autotag"> </a><b class="routine"><i class="routine">recv</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86011" class="autotag"> </a>Receive data from a STREAMS socket.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86013" class="autotag"> </a><b class="routine"><i class="routine">recvfrom</i></b><b>( )</b></div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86015" class="autotag"> </a>Receive a message from a datagram socket.</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86017" class="autotag"> </a><b class="routine"><i class="routine">recvmsg</i></b><b>( )</b></div>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -