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

📄 recv.htm

📁 udt的一个源代码
💻 HTM
字号:
<html><head><meta http-equiv="Content-Language" content="en-us"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>UDT Reference</title></head><body><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber1" bgcolor="#99CCFF" bordercolor="#99CCFF">  <tr>    <td width="100%"><font face="Verdana" size="2"><i>&nbsp;UDT Reference: UDT 	Functions</i></font></td>  </tr></table><h1 style="margin-bottom: 0"><font face="Verdana" size="4">recv</font></h1><p><font face="Verdana" size="2">The <b>recv </b>method receives certain size of data into a local memory buffer.</font></p><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="table1" bgcolor="#C0C0C0" bordercolor="#C0C0C0">  <tr>    <td width="100%">    <p style="margin-top: 0; margin-bottom: 0">    <font size="1" face="Courier New">int recv(<br>&nbsp; UDTSOCKET <font color="#FFFFFF">u</font>,</font></p>	<p style="margin-top: 0; margin-bottom: 0">    <font size="1" face="Courier New">&nbsp; char *<font color="#FFFFFF"><a class="synParam" onclick="showTip(this)">buf</a></font>,</font></p>	<p style="margin-top: 0; margin-bottom: 0">    <font size="1" face="Courier New">&nbsp; int <font color="#FFFFFF"> <a class="synParam" onclick="showTip(this)">len</a></font>,</font></p>	<p style="margin-top: 0; margin-bottom: 0">    <font size="1" face="Courier New">&nbsp; int <a class="synParam" onclick="showTip(this)"><font color="#FFFFFF">flags</font>,</a></font></p>	<p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">&nbsp; int *<font color="#FFFFFF">handle </font>	= NULL,</font></p>	<p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">&nbsp; <a href="structure.htm#MEM">UDT_MEM_ROUTINE</a>	<font color="#FFFFFF">routine</font>&nbsp;= NULL,</font></p>	<p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">&nbsp; void* <font color="#FFFFFF">context    </font>	= NULL</font></p>	<p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">);</font></p>    </td>  </tr></table><h4><font face="Verdana" size="2">Parameters</font></h4><dl>	<dt><font face="Verdana"><i><font size="2">u</font></i><font size="2">	</font></font> </dt>	<dd><font face="Verdana" size="2">[in] Descriptor identifying a connected 	socket. </font></dd>	<dt><font face="Verdana"><i><font size="2">buf</font></i><font size="2">	</font></font> </dt>	<dd><font face="Verdana" size="2">[out] Buffer used to store the incoming 	data. </font></dd>	<dt><font face="Verdana"><i><font size="2">len</font></i><font size="2">	</font></font> </dt>	<dd><font face="Verdana" size="2">[in] Expected length of the data to be 	received. </font>	</dd>	<dt><font face="Verdana"><i><font size="2">flags</font></i><font size="2">	</font></font> </dt>	<dd><font face="Verdana" size="2">[in] Ignored. For compatibility use only.</font></dd>	<dt><font face="Verdana"><i><font size="2">handle</font></i><font size="2">	</font></font> </dt>	<dd><font face="Verdana" size="2">[out] Optional. An descriptor to this <b>recv</b> call.</font></dd>	<dt><font face="Verdana"><i><font size="2">routine</font></i><font size="2">	</font></font> </dt>	<dd><font face="Verdana" size="2">[in] Optional. Function used to process the buffer (received data)	after the receiving is finished. </font></dd>	<dt><font size="2" face="Verdana"><i>context</i></font> </dt>	<dd><font face="Verdana" size="2">[in] Optional. Context parameter used in      the buffer process routine. </font></dd></dl><h4><font face="Verdana" size="2">Return Values</font></h4><p><font face="Verdana" size="2">On success, the actual size of received data is returned; Otherwise,UDT::ERROR is returned and the specific error information can be retrieved by <a href="error.htm">getlasterror</a>. If UDT_RCVTIMEO is set to a positivevalue, zero will be returned if no data is received before the timer expires.</font></p>  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="table2" bordercolordark="#C0C0C0" bordercolorlight="#C0C0C0" width="100%">    <tr>      <th align="center" bgcolor="#C0C0C0" width="133">		<font face="Verdana" size="2">Error Code</font></th>      <th align="center" bgcolor="#C0C0C0" width="812"><b>      <font face="Verdana" size="2">Comment</font></b></th>    </tr>    <tr>      <td width="133">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		2001</font></td>      <td width="812">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		connection broken before send is completed.</font></td>    </tr>    <tr>      <td width="133">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		2002</font></td>      <td width="812">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		<i>u 		</i>is not connected.</font></td>    </tr>    <tr>      <td width="133">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		5004</font></td>      <td width="812">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		<i>u 		</i>is an invalid UDT socket.</font></td>    </tr>    <tr>      <td width="133">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		5010</font></td>      <td width="812">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		cannot use <i>recv</i> in SOCK_DGRAM mode.</font></td>    </tr>    <tr>      <td width="133">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		6002</font></td>      <td width="812">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">		no data is available to be received on a non-blocking socket.</font></td>    </tr>    <tr>      <td width="133">      <font face="Verdana" size="1">6003</font></td>      <td width="812">      <font face="Verdana" size="1">no buffer available for the non-blocking      recv call.</font></td>    </tr>    <tr>      <td width="133">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">6004</font></td>      <td width="812">      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">        an overlapped recv is in progress.</font></td>    </tr>    </table><H4><font face="Verdana" size="2">Description</font></H4><P><font face="Verdana" size="2">The <b>recv </b>method reads certain amount of data from the protocol buffer. If there is not enough data in the buffer, <b>recv</b> only reads the available data in the protocol buffer and returns. On non-blocking socket, <b>recv</b> returns immediately, otherwise <b>recv</b> may wait until some data is available to read.</font></P><P><font face="Verdana" size="2">If the <i>handle</i> parameter is assigned, the <b>recv</b> method is enabled with overlapped IO processing. On blocking mode, UDT will wait until exact the same size of <i>len</i> data are received. On non-blocking mode, <b>recv</b> returns immediately but the successive data continue to be written into the user buffer. In either case, after the IO is completed, the function pointed by <i>routine</i> (if it is not NULL) will be called to process the buffer. Notethat UDT does not duplicate the <i>context</i> parameter: it should remain validuntil the <i>routine</i> is called, and it should be released (if necessary) byapplications. The progressthe overlapped <b>recv</b> can be queried by using <a href="overlap.htm">getoverlappedresult</a>.</font></P><P><font face="Verdana" size="2">Non-blocking overlapped receiving is exclusive.If there is at least one non-blocking overlapped call in progress, all furtherregular <b>recv</b> (non overlapped), <a href="recvfile.htm">recvfile</a>, andblocking overlapped <b>recv</b> will be rejected with error number 6004. This isdue to an implementation limitation.<br><br>Note that, <a href="opt.htm">UDT_RCVTIMEO</a>does NOT apply to overlapped <b>recv</b>.</font></P><H4><font face="Verdana" size="2">See Also</font></H4><P><b><font face="Verdana" size="2"><a href="select.htm">select</a></font></b><font face="Verdana" size="2"><b>, <a href="send.htm">send</a>, <a href="sendfile.htm">sendfile</a>, <a href="recvfile.htm">recvfile</a>,</b><a href="overlap.htm"><b>getoverlappedresult</b></a></font></P></body></html>

⌨️ 快捷键说明

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