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

📄 t_accept.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>t_accept</title></head><body bgcolor=white><center><font size=2>The Single UNIX &reg; Specification, Version 2<br>Copyright &copy; 1997 The Open Group</font></center><hr size=2 noshade><h4>NAME</h4><blockquote>t_accept - accept a connection request</blockquote><h4>SYNOPSIS</h4><blockquote><pre><code>#include &lt;<a href="xti.h.html">xti.h</a>&gt;int t_accept(    int fd,    int resfd,    const struct t_call *call)</code></pre></blockquote><h4>DESCRIPTION</h4><blockquote><pre><P><table  bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Parameters</b><th align=center><b>Before call</b><th align=center><b>After call</b><tr valign=top><td align=left>fd<td align=center>x<td align=center>/<tr valign=top><td align=left>resfd<td align=center>x<td align=center>/<tr valign=top><td align=left>call-&gt<td align=center>addr.maxlen<td align=center>=<tr valign=top><td align=left>call-&gt<td align=center>addr.len<td align=center>x<tr valign=top><td align=left>call-&gt<td align=center>addr.buf<td align=center>? (?)<tr valign=top><td align=left>call-&gt<td align=center>opt.maxlen<td align=center>=<tr valign=top><td align=left>call-&gt<td align=center>opt.len<td align=center>x<tr valign=top><td align=left>call-&gt<td align=center>opt.buf<td align=center>? (?)<tr valign=top><td align=left>call-&gt<td align=center>udata.maxlen<td align=center>=<tr valign=top><td align=left>call-&gt<td align=center>udata.len<td align=center>x<tr valign=top><td align=left>call-&gt<td align=center>udata.buf<td align=center>? (?)<tr valign=top><td align=left>call-&gt<td align=center>sequence<td align=center>x</table></pre><p>This function is issued by a transport user to accept a connection request.  Theparameter <I>fd</I> identifies the local transport endpoint where the connectionindication arrived; <I>resfd</I> specifies the local transport endpoint wherethe connection is to be established, and <I>call</I> contains informationrequired by the transport provider to complete the connection.  The parameter<I>call</I> points to a <B>t_call</B> structure which contains the followingmembers:<pre><code>struct netbuf addr;struct netbuf opt;struct netbuf udata;int sequence;</code></pre><p>In <I>call</I>, <I>addr</I> is the protocol address of the calling transportuser, <I>opt</I> indicates any options associated with the connection,<I>udata</I> points to any user data to be returned to the caller, and<I>sequence</I> is the value returned by<i><a href="t_listen.html">t_listen()</a></i>that uniquely associates the response with a previously received connectionindication.  The address of the caller, <I>addr</I> may be null (length zero).Where <I>addr</I> is not null then it may optionally be checked by XTI.<p>A transport user may accept a connection on either the same, or on adifferent, local transport endpoint than the one on which the connectionindication arrived.  Before the connection can be accepted on the sameendpoint (<I>resfd==fd</I>), the user must have responded to any previousconnection indications received on that transport endpoint (via<i>t_accept()</i>or<i><a href="t_snddis.html">t_snddis()</a></i>).Otherwise,<i>t_accept()</i>will fail and set <I>t_errno</I> to [TINDOUT].<p>If a different transport endpoint is specified (<I>resfd!=fd</I>), then theuser may or may not choose to bind the endpoint before the<i>t_accept()</i>is issued. If the endpoint is not bound prior to the <i>t_accept()</i>,the endpoint must be in the T_UNBND state before the <i>t_accept()</i>is issued, and the transport provider willautomatically bind it to an address that is appropriatefor the protocol concerned.If the transport user chooses to bind theendpoint it must be bound to a protocol address with a <I>qlen</I> of zero andmust be in the T_IDLE state before the<i>t_accept()</i>is issued.<p>Responding endpoints should be supplied to <i>t_accept()</i>in the state T_UNBND.<p>The call to <i>t_accept()</i>may fail with t_errno setto [TLOOK] if there are indications (for example connect ordisconnect) waiting to be received on endpoint <I>fd</I>.Applications should be prepared for such a failure.<p>The <I>udata</I> argument enables the called transport user to send user datato the caller and the amount of user data must not exceed the limits supportedby the transport provider as returned in the <I>connect</I> field of the<I>info</I> argument of<i><a href="t_open.html">t_open()</a></i>or<i><a href="t_getinfo.html">t_getinfo()</a></i>.If the <I>len</I> field of <I>udata</I> is zero, no data will be sent to thecaller.  All the <I>maxlen</I> fields are meaningless.<p>When the user does not indicate any option (<I>call-&gt;opt.len</I> = 0)the connection shall be accepted with the option values currentlyset for the responding endpoint <I>resfd</I>(see <xref href=rnprop></xref>and<xref href=omtep></xref>).</blockquote><h4>CAVEATS</h4><blockquote>There may be transport provider-specific restrictions on address binding.  See<xref href=istpi></xref>and<xref href=ipsi></xref>.<p>Some transport providers do not differentiate between a connection indication andthe connection itself.  If the connection has already been established after asuccessful return of<i><a href="t_listen.html">t_listen()</a></i>,<i>t_accept()</i>will assign the existing connection to the transport endpoint specified by<I>resfd</I> (see<xref href=ipsi></xref>).</blockquote><h4>VALID STATES</h4><blockquote>fd: T_INCON<br>resfd (fd!=resfd): T_IDLE, T_UNBND</blockquote><h4>ERRORS</h4><blockquote>On failure,<I>t_errno</I>is set to one of the following:<dl compact><dt>[TACCES]<dd>The user does not have permission to accept a connection on the respondingtransport endpoint or to use the specified options.<dt>[TBADADDR]<dd>The specified protocol address was in an incorrect format orcontained illegal information.<dt>[TBADDATA]<dd>The amount of user data specified was not within the bounds allowed by thetransport provider.<dt>[TBADF]<dd>The file descriptor <I>fd</I> or <I>resfd</I> does not refer to a transportendpoint.<dt>[TBADOPT]<dd>The specified options were in an incorrect format or contained illegalinformation.<dt>[TBADSEQ]<dd>Either an invalid sequence number was specified, or avalid sequence number was specified but the connectionrequest was aborted by the peer.In the latter case, its T_DISCONNECT event will be received on the listening endpoint.<dt>[TINDOUT]<dd>The function was called with <I>fd==resfd</I> but there are outstandingconnection indications on the endpoint.  Those other connection indicationsmust be handled either by rejecting them via <I>t_snddis</I>(3) or acceptingthem on a different endpoint via <I>t_accept</I>(3).<dt>[TLOOK]<dd>An asynchronous event has occurred on the transport endpoint referenced by<I>fd</I> and requires immediate attention.<dt>[TNOTSUPPORT]<dd>This function is not supported by the underlying transport provider.<dt>[TOUTSTATE]<dd>The communications endpoint referenced by <I>fd</I>or <I>resfd</I>is not in one of the states in which a call to this function is valid.<dt>[TPROTO]<dd>This error indicates that a communication problem has been detected betweenXTI and the transport provider for which there is no other suitable XTIerror<I>(t_errno)</I>.<dt>[TPROVMISMATCH]<dd>The file descriptors <I>fd</I> and <I>resfd</I> do not refer to the sametransport provider.<dt>[TRESADDR]<dd>This transport provider requires both <I>fd</I> and <I>resfd</I> to be bound tothe same address.  This error results if they are not.<dt>[TRESQLEN]<dd>The endpoint referenced by <I>resfd</I> (where <I>resfd</I> != <I>fd</I>) wasbound to a protocol address with a <I>qlen</I> that is greater than zero.<dt>[TSYSERR]<dd>A system error has occurred during execution of this function.</dl></blockquote><h4>RETURN VALUE</h4><blockquote>Upon successful completion, a value of 0 is returned.  Otherwise, a value of-1 is returned and<I>t_errno</I>is set to indicate an error.</blockquote><h4>SEE ALSO</h4><blockquote><i><a href="t_connect.html">t_connect()</a></i>,<i><a href="t_getstate.html">t_getstate()</a></i>,<i><a href="t_listen.html">t_listen()</a></i>,<i><a href="t_open.html">t_open()</a></i>,<i><a href="t_optmgmt.html">t_optmgmt()</a></i>,<i><a href="t_rcvconnect.html">t_rcvconnect()</a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

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