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

📄 recvfile.htm

📁 Last Update: Jan 22 2009 可靠UDP传输, 一套高效的基于windows平台的C++ 开发库
💻 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>recvfile</strong></h4>
<p>The <b>recvfile</b> method reads certain amount of data into a local file.</p>

<div class="code">int64_t recvfile(<br />
&nbsp; UDTSOCKET <font color="#FFFFFF">u</font>,<br />
&nbsp; ofstream& <font color="#FFFFFF">ofs</font>,<br />
&nbsp; int64_t <font color="#FFFFFF">offset</font>,<br />
&nbsp; int64_t <font color="#FFFFFF">size</font>,<br />
&nbsp; int <font color="#FFFFFF">block</font> = 366000<br />
);</div>

<h5>Parameters</h5>
<dl>
  <dt><i>u</i></dt>
  <dd>[in] Descriptor identifying a connected socket.</dd>
  <dt><em>ofs</em></dt>
  <dd>[in] C++ ofstream descriptor for the file to store incoming data.</dd>
  <dt><em>offset</em></dt>
  <dd>[in] The offset position from where the data is written into the file.</dd>
  <dt><em>size</em></dt>
  <dd>[in] The total size to be received.</dd>
  <dt><em>block</em></dt>
  <dd>[in] Optional. The size of every data block for file IO.</dd>
</dl>

<h5>Return Value</h5>
<p>On success, <b>recvfile</b> returns the actual size of received data. Otherwise UDT::ERROR is returned and specific error information can be retrieved by <a 
href="error.htm">getlasterror</a>.</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>ECONNLOST</td>
    <td>2001</td>
    <td>connection has been broken and no data left in receiver buffer.</td>
  </tr>
  <tr>
    <td>ENOCONN</td>
    <td>2002</td>
    <td><i>u</i> is not connected.</td>
  </tr>
  <tr>
    <td>EFILE</td>
    <td>4000</td>
    <td>File or disk system errors.</td>
  </tr>
  <tr>
    <td>EINVSOCK</td>
    <td>5004</td>
    <td><i>u</i> is not an valid socket.</td>
  </tr>
  <tr>
    <td>EDGRAMILL</td>
    <td>5010</td>
    <td>cannot use <i>recvfile</i> in SOCK_DGRAM mode.</td>
  </tr>
</table>

<h5>Description</h5>
<p>The <strong>recvfile</strong> method reads certain amount of data and write it into a local file. It is always in blocking mode and will not return until the exact amount of data is 
received, file handler is bad (e.g., no disk space), or the connection is broken. Neither UDT_RCVSYN nor UDT_RCVTIMEO affects this method. The actual size of data to expect must be known before calling recvfile, otherwise deadlock may occur due to insufficient incoming data.</p>
<h5>See Also</h5>
<p><strong><a href="send.htm">send</a>, <a href="sendfile.htm">sendfile</a>, <a href="recv.htm">recv</a></strong></p>
<p>&nbsp;</p>

</body>
</html>

⌨️ 快捷键说明

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