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

📄 select.htm

📁 udt.sdk.4.0,UDP的可靠传输项目UDT(开源),采用了类似TCP的滑动窗口协议,在 udt.sdk.3.2 的基础上作了改进,使适用于网格计算
💻 HTM
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title> UDT Reference</title><link rel="stylesheet" href="udtdoc.css" type="text/css" /></head><body><div class="ref_head">&nbsp;UDT Reference: Functions</div><h4 class="func_name"><strong>select</strong></h4><p>The <b>select</b> method queries one or more groups of UDT sockets.</p><div class="code">int select(<br />&nbsp; int <font color="#FFFFFF">nfds</font>,<br />&nbsp; UDSET* <font color="#FFFFFF">readfds</font>,<br />&nbsp; UDSET* <font color="#FFFFFF">writefds</font>,<br />&nbsp; UDSET* <font color="#FFFFFF">exceptfds</font>,<br />&nbsp; const struct timeval* <font color="#FFFFFF">timeout</font><br />);</div><h5>Parameters</h5><dl>  <dt><i>nfds</i></dt>  <dd>[in] Ignored. For compatibility only.</dd>  <dt><em>readfds</em></dt>  <dd>[in, out] Optional pointer to a set of sockets to be checked for readability.</dd>  <dt><em>writefds</em></dt>  <dd>[in, out] Optional pointer to a set of sockets to be checked for writability.</dd>  <dt><em>exceptfds</em></dt>  <dd>[in, out] Ignored. For compatibility only.</dd>  <dt><em>timeout</em></dt>  <dd>[in] The future time when this call should be timeout.</dd></dl><h5>Return Value</h5><p>If any of the read or write query is positive, <strong>select</strong> returns the number of UDT sockets that are read for read/write. If no socket is ready before timeout, zero is returned. If there is any error, UDT::ERROR is returned and the specific error information can be retrieved using <a href="error.htm">getlasterror</a>. The <i>readfds</i> and/or <i>writefds</i> will be updated to contain the ready sockets only.</p><table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC">  <tr>    <td width="17%" class="table_headline"><strong>Error Name</strong></td>    <td width="17%" class="table_headline"><strong>Error Code</strong></td>    <td width="83%" class="table_headline"><strong>Comment</strong></td>  </tr>  <tr>    <td>EINVPARAM</td>    <td>5003</td>    <td>All three socket sets are empty or at least one of the socket is invalid.</td>  </tr></table><h5>Description</h5><p>The UDSET is a structure to store the UDT socket descriptors. If should only be processed with the following macros.</p><dl>  <dt><b>UD_CLR</b>(<i>u, *set</i>)</dt>  <dd>Removes the descriptor <i>u</i> from <i>set</i>.</dd>  <dt><b>UD_ISSET</b>(<i>u, *set</i>)</dt>  <dd>Nonzero if <i>u</i> is a member of <i>set</i>; otherwise zero.</dd>  <dt><b>UD_SET</b>(<i>u, *set</i>)</dt>  <dd>Add descriptor <i>u</i> to <i>set</i>.</dd>  <dt><b>UD_ZERO</b>(<i>*set</i>)</dt>  <dd>Initialize <i>set</i> to an empty set.</dd></dl><p>The UDT descriptors sets originaly contains the sockets whose status is to be queried. When <strong>select</strong> returns, the descriptors sets only contain the sockets that are ready for IO. UD_ISSET can be used to check which one is ready.</p><p><i>readfds</i> is used to detect if any socket in this set is available for reading (recv, recvmsg), for accepting a new connection (accept), or the associated connection is broken. <i>writefds</i> is used to detect if any socket in this set has available buffer for sending (send, sendmsg). Currently <i>exceptfds</i> is not used.</p><h5>Example</h5><p>The following example shows how to check if a UDT socket is available for <strong>recv</strong>.</p><div class="code"><p>UDTSOCKET u;<br>...<br><br>timeval tv;<br>UDSET readfds;<br><br>tv.tv_sec = 1;<br>tv.tv_usec = 0;<br><br>UD_ZERO(&readfds);<br>UD_SET(u, &readfds);<br><br>int res = UDT::select(0, &readfds, NULL, NULL, &tv);<br><br>if ((res != UDT::ERROR) && (UD_ISSET(u, &readfds)))<br>&nbsp;&nbsp;&nbsp;// read data from u.<br>else<br>&nbsp;&nbsp;&nbsp;// timeout or error<br></p></div><p>&nbsp;</p></body></html>

⌨️ 快捷键说明

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