TransmitFile

Transmits file data over an overlapped socket handle.

Library:LibC
Standard:Microsoft
Service:Winsock

Syntax

  BOOL PASCAL FAR TransmitFile (
      IN SOCKET                   hSocket,
      IN HANDLE                   hFile,
      IN DWORD                    nNumberOfBytesToWrite,
      IN DWORD                    nNumberOfBytesPerSend,
      IN LPOVERLAPPED             lpOverlapped,
      IN LPTRANSMIT_FILE_BUFFERS  lpTransmitBuffers,
      IN DWORD                    dwReserved );
  

Parameters

hSocket

(IN) Specifies the handle to the socket.

hFile

(IN) Specifies the handle to the open file that is being transmitted.

nNumberOfBytesToWrite

(IN) Specifies the number of bytes of data to transmit. The TransmitFile function returns when this number of bytes have been transmitted or when an error occurs, whichever occurs first.

nNumberOfBytesPerSend

(IN) Specifies the size of the data block, in bytes, to be sent in each operation. Use 0 to set the block size to the default value.

lpOverlapped

(IN) Points to an OVERLAPPED structure, which is used by all overlapped sockets for overlapped (asynchronous) I/O operations.

lpTransmitBuffers

(IN) Points to a TRANSMIT_FILE_BUFFERS data structure that contains pointers to data to send before and after the file data is sent. You can set this parameter to null if you want to transmit only the file data.

dwReserved

(IN) Reserved. On NetWare, this parameter is ignored.

Return Values

If successful, returns 0. Otherwise, returns -1. To get extended error information, call the WSAGetLastError function.

If an overlapped I/O operation is not complete before the function returns, TransmitFile returns -1 and the WSAGetLastError function returns ERROR_IO_PENDING or WSA_IO_PENDING. You should design your application to handle ERROR_IO_PENDING and WSA_IO_PENDING

Remarks

On NetWare, any calls made to TransmitFile must be done on overlapped sockets. An overlapped socket has the WSA_FLAGS_OVERLAPPED flag set and the callback set to SKTS_WORKTODOCALLBACKS. If you use the WSASocket function to create the socket, you must pass in the WSA_FLAG_OVERLAPPED bit in the dwFlagsParameter. If the sockets aren't overlapped, TransmitFile returns WASEINVAL.