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

📄 t-file.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="table1" bgcolor="#99CCFF" bordercolor="#99CCFF">  <tr>    <td width="100%"><font face="Verdana" size="2"><i>&nbsp;UDT </i></font><i>	<font face="Verdana" size="2">Tutorial</font></i></td>  </tr></table><h1><font face="Verdana" size="4">Transfer files using UDT</font></h1><p><font face="Verdana" size="2">Files can be sent or received at any time once the UDT connection is established. There is NO non-blocking mode for file sending or receiving, no matter how the <a href="opt.htm">UDT_SNDSYN</a> and<a href="opt.htm">UDT_RCVSYN</a> options are set.</font></p><p><font face="Verdana" size="2">In UDT, file transfer uses C++ <u>fstream</u> standard class to handle the files. The following examples show the usage of<a href="sendfile.htm">sendfile</a> and <a href="recvfile.htm">recvfile</a>.</font></p><h4><font face="Verdana" size="2">Example: send a file using UDT</font></h4><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="table2" bgcolor="#C0C0C0" bordercolor="#C0C0C0">  <tr>    <td width="100%">    <p style="margin-top: 0; margin-bottom: 0">	<font size="1" face="Courier New">    UDTSOCKET fhandle;</font></p>    <p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">...</font></p>    <p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>    <p style="margin-top: 0; margin-bottom: 0"><font size="1" face="Courier New">    ifstream&amp; ifs(&quot;largefile.dat&quot;);</font></p>    <p style="margin-top: 0; margin-bottom: 0">    <font size="1" face="Courier New">ifs.seekg(0, ios::end);</font></p>    <p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">int64_t size = ifs.tellg();</font></p>    <p style="margin-top: 0; margin-bottom: 0">    <font size="1" face="Courier New">ifs.seekg(0, ios::beg);</font></p>	<p style="margin-top: 0; margin-bottom: 0">    &nbsp;</p>	<p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">if (UDT::ERROR == UDT::sendfile(fhandle, 	ifs, 0, size))<br>	{<br>&nbsp;&nbsp; cout &lt;&lt; &quot;sendfile: &quot; &lt;&lt; UDT::getlasterror().getErrorMessage();<br>&nbsp;&nbsp; return 0;<br>	}</font></p>    </td>  </tr></table><h4><font face="Verdana" size="2">Example: receive data into a file using UDT</font></h4><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="table3" bgcolor="#C0C0C0" bordercolor="#C0C0C0">  <tr>    <td width="100%">    <p style="margin-top: 0; margin-bottom: 0">	<font size="1" face="Courier New">    UDTSOCKET recver;</font></p>    <p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">...</font></p>    <p style="margin-top: 0; margin-bottom: 0">    &nbsp;</p>    <p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">ofstream&amp; ofs(&quot;largefile.dat&quot;);</font></p>	<p style="margin-top: 0; margin-bottom: 0">    &nbsp;</p>	<p style="margin-top: 0; margin-bottom: 0">    <font face="Courier New" size="1">if (UDT::ERROR == UDT::recvfile(fhandle, 	ofs, 0, size))<br>	{<br>&nbsp;&nbsp; cout &lt;&lt; &quot;recvfile: &quot; &lt;&lt; UDT::getlasterror().getErrorMessage();<br>&nbsp;&nbsp; return 0;<br>	}</font></p></td>  </tr></table><p style="margin-top: 0; margin-bottom: 0">&nbsp;</p><p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2">Note that a sent file is not necessarily received by <a href="recvfile.htm">recvfile</a>, and vice versa. Also note that fstream in GCC 3.0 does NOT support large file(&gt; 2GB) and please use other versions of GCC to compile UDT if you need largefile support.</font></p></body></html>

⌨️ 快捷键说明

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