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] The offset position from where the data is read from the file.
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.
Description

The sendfile method sends certain amount of out of a local file. It is always in blocking mode and will not return until the exact amount of data is sent, EOF is reached, or the connection is broken. Neither UDT_SNDSYN nor UDT_SNDTIMEO affects this method.

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

See Also

send, recv, recvfile