UDT Reference: UDT Functions |
The sendfile method sends out a file stream.
int64_t sendfile(
UDTSOCKET u, const int64_t& offset, const int64_t& size,
const int&
block = 7340000 |
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. |
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.