Writes data to a socket.
#include <iocp.h>
boolean_t WriteFile (FileDescriptor, Buffer, WriteCount, AmountWritten, Overlapped)
HANDLE FileDescriptor;
LPVOID Buffer;
DWORD WriteCount;
LPDWORD AmountWritten;
LPOVERLAPPED Overlapped;
The WriteFile subroutine writes the number of bytes specified by the WriteCount parameter from the buffer indicated by the Buffer parameter to the FileDescriptor parameter. The number of bytes written is saved in the AmountWritten parameter. The Overlapped parameter indicates whether or not the operation can be handled asynchronously.
The WriteFile subroutine returns a boolean (an integer) indicating whether or not the request has been completed.
The WriteFile subroutine is part of the I/O Completion Port (IOCP) kernel extension.
Item | Description |
---|---|
FileDescriptor | Specifies a valid file descriptor obtained from a call to the socket or accept subroutines. |
Buffer | Specifies the buffer from which the data will be written. |
WriteCount | Specifies the maximum number of bytes to write. |
AmountWritten | Specifies the number of bytes written. The parameter is set by the subroutine. |
Overlapped | Specifies an overlapped structure indicating whether or not the request can be handled asynchronously. |
Upon successful completion, the WriteFile subroutine returns a boolean indicating the request has been completed.
Item | Description |
---|---|
EINPROGRESS | The write request can not be immediately satisfied and will be handled asynchronously. A completion packet will be sent to the associated completion port upon completion. |
EAGAIN | The write request cannot be immediately satisfied and cannot be handled asynchronously. |
EINVAL | The FileDescriptor is invalid. |
void buffer;
int amount_written;
b=WriteFile (34, &buffer, 128, &amount_written, NULL);
void buffer;
int amount_written;
LPOVERLAPPED overlapped;
b = ReadFile (34, &buffer, 128, &amount_written, overlapped);