?? recvfile.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"> 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 />
UDTSOCKET <font color="#FFFFFF">u</font>,<br />
ofstream& <font color="#FFFFFF">ofs</font>,<br />
int64_t <font color="#FFFFFF">offset</font>,<br />
int64_t <font color="#FFFFFF">size</font>,<br />
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> </p>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -