Ok here it is, for those who might need it in the future:
[DllImport("mswsock.dll", SetLastError=true)]
internal static extern bool TransmitFile(
[In] IntPtr socket,
[In] IntPtr fileHandle,
[In] int numberOfBytesToWrite,
[In] int numberOfBytesPerSend,
[In] IntPtr overlapped,
[In] TransmitFileBuffers buffers,
[In] TransmitFileFlags flags);
[StructLayout(LayoutKind.Sequential)]
internal class TransmitFileBuffers
{
internal IntPtr preBuffer;
internal int preBufferLength;
internal IntPtr postBuffer;
internal int postBufferLength;
public TransmitFileBuffers()
{
}
}
[Flags]
public enum TransmitFileFlags
{
// Fields
Disconnect = 1,
ReuseSocket = 2,
UseDefaultWorkerThread = 0,
UseKernelApc = 0x20,
UseSystemThread = 0x10,
WriteBehind = 4
}
In my usage, I can simply send the IntPtr.Zero for the overlapped parameter
and it does the job. I am going to do some performance testing to verify
that it is actually better than reading the file and writing to the socket.
Thanks for everyone's help.
Shariq