UDT Reference: UDT Functions

sendfile

The sendfile method sends out a file stream.

int64_t sendfile(

   UDTSOCKET u,
   ifstream& ifs,

   const int64_t& offset,

   const int64_t& size,

   const int& block = 7340000
);

Parameters

u
[in] Handle to a connected socket.
ifs
[in] ifstream descriptor of the file to transferred.
offset
[in] the position from where file is read and sent.
size
[in] the total size to be transferred.
block
[in] Optional. data block size for each reading.

Return Values

On success, the actual size of data sent is returned. Otherwise, UDT::ERROR is returned and the specific error information can be retrieved using getlasterror.

Error Code Comment

2000

connection is broken before the IO completes.

5000

file system error.

5004

u is an invalid UDT socket.

5010

cannot use sendfile in SOCK_DGRAM mode.

Description

The sendfile method sends data from a file stream. To send a whole file, simply set the offset to 0, and the size to the actual file size.

The data sending and receiving are orthogonal, i.e., the peer side can use either recv or recvfile to receive data, no matter send or sendfile is used at the other side.

sendfile is always in blocking mode. The UDT_SNDSYN option only affects send. In addition, UDT_SNDTIMEO does not apply to this method.

See Also

recv, recvfile