TcpConnection.sendFile

SendResult sendFile(HANDLE fileHandle, ulong offset, size_t count) @trusted nothrow

Send a file over the connection using zero-copy TransmitFile.

When IOCP overlapped mode is active and TransmitFile is available, the file is transferred directly from kernel file buffers to the socket without copying through userspace. Falls back to regular send() in WSAPoll mode.

The file handle is closed after the transfer completes or on error. The caller must not close the handle after calling this method.

Parameters

fileHandleWin32 file handle (opened with FILE_FLAG_OVERLAPPED for IOCP mode). Ownership transfers to the connection.
offsetByte offset to start sending from.
countNumber of bytes to send (0 = entire file from offset).

Returns

  • SendResult.OK — transfer queued successfully
  • SendResult.CLOSED — connection not in CONNECTED state
  • SendResult.ERROR — system error