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

📄 t_bind.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_bind</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_bind - bind an address to a transport endpoint</blockquote><h4>SYNOPSIS</h4><blockquote><pre><code>#include &lt;<a href="xti.h.html">xti.h</a>&gt;int t_bind(    int fd,    const struct t_bind *req,    struct t_bind *ret)</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>req-&gt<td align=center>addr.maxlen<td align=center>=<tr valign=top><td align=left>req-&gt<td align=center>addr.len<td align=center>x0<tr valign=top><td align=left>req-&gt<td align=center>addr.buf<td align=center>x (x)<tr valign=top><td align=left>req-&gt<td align=center>qlen<td align=center>x0<tr valign=top><td align=left>ret-&gt<td align=center>addr.maxlen<td align=center>x<tr valign=top><td align=left>ret-&gt<td align=center>addr.len<td align=center>/<tr valign=top><td align=left>ret-&gt<td align=center>addr.buf<td align=center>?<tr valign=top><td align=left>ret-&gt<td align=center>qlen<td align=center>/</table></pre><p><I>ret-&gt;addr.buf</I> (the pointer itself, not the bufferit points to) is also unchanged.<p>This function associates a protocol addresswith the transport endpoint specified by<I>fd</I>and activates that transport endpoint.In connection mode, the transport provider may begin enqueuing incomingconnect indications, or servicing a connectionrequest on the transport endpoint.In connectionless-mode, the transport user may send or receivedata units through the transport endpoint.<p>The<I>req</I>and<I>ret</I>arguments point to a<B>t_bind</B>structure containing the following members:<pre><code>struct netbuf addr;unsigned qlen;</code></pre><p>The<I>addr</I>field of the<B>t_bind</B>structure specifies a protocol address, and the<I>qlen</I>field is used to indicate the maximum number of outstandingconnection indications.<p>The parameter<I>req</I>is used to request that an address, represented by the<B>netbuf</B>structure, be bound to the given transport endpoint.The parameter<I>len</I>specifies the number of bytes in the address, and<I>buf</I>points to the address buffer.The parameter<I>maxlen</I>has no meaning for the<I>req</I>argument.On return,<I>ret</I>contains an encoding for the address that thetransport provider actually bound to the transport endpoint; ifan address was specified in <I>req</I>,this will be an encoding of the same address.In<I>ret</I>,the user specifies<I>maxlen,</I>which is the maximum size of the address buffer, and<I>buf</I>which points to the buffer where the address is to be placed.On return,<I>len</I>specifies the number of bytes in the bound address,and<I>buf</I>points to the bound address.If<I>maxlen</I>equals zero, no addressis returned. If <I>maxlen</I>is greater than zero and less thanthe length of the address, <i>t_bind()</i>fails with<I>t_errno</I>set to [TBUFOVFLW].<p>If the requested address is not available,<i>t_bind()</i>will return -1 with<I>t_errno</I>set as appropriate.If no address is specified in<I>req</I>(the<I>len</I>field of<I>addr</I>in<I>req</I>is zero or<I>req</I>is NULL),the transport provider will assign an appropriate address to be bound,and will return that address in the<I>addr</I>field of<I>ret</I>.If the transport provider could not allocate an address,<i>t_bind()</i>will fail with<I>t_errno</I>set to [TNOADDR].<p>The parameter<I>req</I>may be a null pointer if the user does not wish to specify anaddress to be bound.Here, the value of<I>qlen</I>is assumed to be zero, and the transport provider will assign anaddress to the transport endpoint.Similarly,<I>ret</I>may be a null pointer if the user does not care what address wasbound by the provider and is not interested in the negotiatedvalue of<I>qlen</I>.It is valid to set<I>req</I>and<I>ret</I>tothe null pointerfor the same call, in which case the provider chooses the addressto bind to the transport endpoint and does not return thatinformation to the user.<p>The<I>qlen</I>field has meaning only when initialising a connection-mode service.It specifies the number of outstanding connection indications that the transportprovider should support for the given transport endpoint.An outstanding connection indication is one that has been passed to the transportuser by the transport provider but which has not been accepted or rejected.A value of<I>qlen</I>greater than zerois only meaningful when issued by a passive transport user that expectsother users to call it.The value of<I>qlen</I>will be negotiated by the transport provider and may be changedif the transport provider cannot support the specified number ofoutstanding connection indications.However, this value of<I>qlen</I>will never be negotiated from a requested value greater than zero to zero.This is a requirement on transport providers; see <B>CAVEATS</B> below.On return, the<I>qlen</I>field in<I>ret</I>will contain the negotiated value.<p>If<I>fd</I>refers to a connection-mode service,this function allowsmore than one transport endpoint to be bound to thesame protocol address (however, the transport providermust also support this capability), but it is not possible to bind more thanone protocol address to the same transport endpoint.If a user binds more than one transport endpoint to the same protocoladdress, only one endpoint can be used to listen forconnection indications associated with that protocol address.In other words, only one<i>t_bind()</i>for a given protocol address may specify a value of<I>qlen</I>greater than zero.In this way, the transport provider can identify which transport endpointshould be notified of an incoming connection indication.If a user attempts to bind a protocol address to a second transportendpoint with a value of<I>qlen</I>greater than zero,<i>t_bind()</i>will return -1 and set<I>t_errno</I>to [TADDRBUSY].When a user accepts a connection on the transport endpoint that is beingused as the listening endpoint, the bound protocol addresswill be found to be busy for the duration of the connection,until a<i><a href="t_unbind.html">t_unbind()</a></i>or<i><a href="t_close.html">t_close()</a></i>call has been issued.No other transport endpoints may be bound for listening on that same protocoladdress while that initial listening endpoint is active (in the datatransfer phase or in the T_IDLEstate).This will prevent more than one transport endpoint bound to the sameprotocol address from accepting connection indications.<p>If <I>fd</I>refers to connectionless mode service, this functionallows for more than one transport endpoint to be associatedwith a protocol address, where the underlying transport providersupports this capability (often in conjunction with value of aprotocol-specific option). If a user attempts to bind a secondtransport endpoint to an already bound protocol address when suchcapability is not supported for a transport provider,<i>t_bind()</i>will return -1 and set<I>t_errno</I>to [TADDRBUSY].</blockquote><h4>VALID STATES</h4><blockquote>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 use the specified address.<dt>[TADDRBUSY]<dd>The requested address is in use.<dt>[TBADADDR]<dd>The specified protocol address was in an incorrect format orcontained illegal information.<dt>[TBADF]<dd>The specified file descriptor does not refer to a transport endpoint.<dt>[TBUFOVFLW]<dd>The number of bytes allowed for an incoming argument<I>(maxlen)</I>is greater than 0 but notsufficient to store the value of that argument.The provider's state will change to T_IDLEand the information to be returned in<I>ret</I>will be discarded.<dt>[TOUTSTATE]<dd>The communications endpoint referenced by <I>fd</I>is not in one of the states in which a call to this function is valid.<dt>[TNOADDR]<dd>The transport provider could not allocate an address.<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>[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_accept.html">t_accept()</a></i>,<i><a href="t_alloc.html">t_alloc()</a></i>,<i><a href="t_close.html">t_close()</a></i>,<i><a href="t_connect.html">t_connect()</a></i>,<i><a href="t_unbind.html">t_unbind()</a></i>.</blockquote><h4>CAVEATS</h4><blockquote>The requirement that the value of<I>qlen</I>never be negotiated from a requested value greater than zero to zero impliesthat transport providers, rather than the XTI implementation itself,accept this restriction.<p>An implementation need not allow an applicationexplicitly to bind more than one communications endpointto a single protocol address, while permitting more thanone connection to be accepted to the same protocoladdress. That means that although an attempt to bind acommunications endpoint to some address with <I>qlen=0</I>might be rejected with [TADDRBUSY], the user may neverthelessuse this (unbound) endpoint as a responding endpoint in acall to <i><a href="t_accept.html">t_accept()</a></i>.To become independent of suchimplementation differences, the user should supply unboundresponding endpoints to <i><a href="t_accept.html">t_accept()</a></i>.<p>The local address bound to an endpoint may change as result of a<i><a href="t_accept.html">t_accept()</a></i>or <i><a href="t_connect.html">t_connect()</a></i>call. Such changes are not necessarilyreversed when the connection is released.</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 + -