UDT Reference

UDT Reference: Functions

#### sendfile

The sendfile method sends out part or the whole of a local file.

int64_t sendfile(
UDTSOCKET u,
fstream& ifs,
const int64_t& offset,
const int64_t size,
const int block = 7320000
);

##### Parameters

u
  [in] Descriptor identifying a connected socket.
ifs
  [in] C++ fstream descriptor for the file to read data from.
offset
  [in, out] The offset position from where the data is read from the file. After the call returns, this value holds the updated read position.
size
  [in] The total size to be sent.
block
  [in] Optional. The size of every data block for file IO.

##### Return Value

On success, sendfile returns the actual size of data that has been sent. Otherwise UDT::ERROR is returned and specific error information can be retrieved by getlasterror.

Error Name | Error Code | Comment
ECONNLOST | 2001 | connection has been broken.
ENOCONN | 2002 | u is not connected.
EINVOP | 4000 | File or disk system errors.
EINVSOCK | 5004 | u is not an valid socket.
EDGRAMILL | 5010 | cannot use sendfile in SOCK_DGRAM mode.
EPEERERR | 7000 | The peer side has an unrecoverable error and this call has to be cancelled.

##### Description

The sendfile method sends certain amount of out of a local file. It is always in blocking mode an neither UDT_SNDSYN nor UDT_SNDTIMEO affects this method. However, the sendfile method has a streaming semantics same as send.

Note that sendfile does NOT nessesarily require recvfile at the peer side. Sendfile/recvfile and send/recv are orthogonal UDT methods.

##### See Also

send, recv, recvfile