UDT Tutorial |
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 UDT_SNDSYN and UDT_RCVSYN options are set.
In UDT, file transfer uses C++ fstream standard class to handle the files. The following examples show the usage of sendfile and recvfile.
UDTSOCKET fhandle; ...
ifstream& ifs("largefile.dat"); ifs.seekg(0, ios::end); int64_t size = ifs.tellg(); ifs.seekg(0, ios::beg);
if (UDT::ERROR == UDT::sendfile(fhandle,
ifs, 0, size)) |
UDTSOCKET recver; ...
ofstream& ofs("largefile.dat");
if (UDT::ERROR == UDT::recvfile(fhandle,
ofs, 0, size)) |
Note that a sent file is not necessarily received by recvfile, and vice versa. Also note that fstream in GCC 3.0 does NOT support large file (> 2GB) and please use other versions of GCC to compile UDT if you need large file support.