|
TransmitFile
This function is a Microsoft-specific extension to the Windows Sockets
specification. For more information, see Microsoft Extensions and Windows Sockets 2.
The Windows Sockets TransmitFile function transmits file data over a connected socket handle. This function
uses the operating system's cache manager to retrieve the file data, and provides
high-performance file data transfer over sockets.
BOOL TransmitFile(
SOCKET hSocket,
|
| HANDLE hFile,
|
| DWORD nNumberOfBytesToWrite,
|
| DWORD nNumberOfBytesPerSend,
|
| LPOVERLAPPED lpOverlapped,
|
| LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
|
| DWORD dwFlags
|
| );
|
|
Parameters
hSocket
A handle to a connected socket. The function will transmit the file data over
this socket.
The socket specified by hSocket must be a connection-oriented socket.
Sockets of type SOCK_STREAM, SOCK_SEQPACKET, or SOCK_RDM are
connection-oriented sockets. The TransmitFile function does not support datagram sockets.
hFile
A handle to an open file. The function transmits this file's data. The
operating system reads the file data sequentially. You can improve caching performance
by opening the handle with the FILE_FLAG_SEQUENTIAL_SCAN.
nNumberOfBytesToWrite
The number of bytes to transmit. The function completes when it has sent this
many bytes, or if an error occurs.
Set this parameter to zero to transmit the entire file.
nNumberOfBytesPerSend
The size of each block of data sent per send operation. This specification is
for use by the sockets layer of the operating system.
Set this parameter to zero to have the sockets layer select a default send
size.
This parameter is useful for message protocols that have limitations on the
size of individual send requests.
lpOverlapped
Pointer to an OVERLAPPED structure. If the socket handle has been opened as overlapped, specify this
parameter in order to achieve an overlapped (aysnchronous) I/O operation. By
default, socket handles are opened as overlapped.
You can use lpOverlapped to specify an offset within the file at which to start the file data transfer
by setting the Offset and OffsetHigh member of the OVERLAPPED structure. If lpOverlapped is NULL, the transmission of data always starts at the current byte offset in
the file.
When lpOverlapped is not NULL, the overlapped I/O might not finish before TransmitFile returns. In that case, the TransmitFile function returns FALSE, and GetLastError returns ERROR_IO_PENDING. This lets the caller continue processing while the
file transmission operation completes. The operating system will set the event
specified by the hEvent member of the OVERLAPPED structure, or the socket specified by hSocket, to the signaled state upon completion of the data transmission request.
lpTransmitBuffers
Pointer to a TRANSMIT_FILE_BUFFERS data structure that contains pointers to data to send before and after the
file data is sent. Set this parameter to NULL if you only want to transmit the
file data.
dwFlags
An attribute that has three settings:
TF_DISCONNECT
Start a transport-level disconnect after all the file data has been queued for
transmission.
TF_REUSE_SOCKET
Prepare the socket handle to be reused. When the TransmitFile request
completes, the socket handle can be passed to the AcceptEx function. It is only valid if TF_DISCONNECT is also specified.
TF_WRITE_BEHIND
Complete the TransmitFile request immediately, without pending. If this flag is specified and TransmitFile succeeds, then the data has been accepted by the system but not necessarily
acknowledged by the remote end. If TransmitFile returns TRUE, there will be no completion port indication for the I/O. Do not
use this setting with the other two settings.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error
information, call GetLastError. The function returns FALSE if an overlapped I/O operation is not complete
before TransmitFile returns. In that case, GetLastError returns ERROR_IO_PENDING.
Remarks
The Windows NT Server optimizes the TransmitFile function for high performance. The Windows NT Workstation optimizes the
function for minimum memory and resource utilization. Expect better performance
results when using TransmitFile on Windows NT Server.
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|