Reads data from a socket.
#include <iocp.h>
boolean_t ReadFile (FileDescriptor, Buffer, ReadCount, AmountRead, Overlapped)
HANDLE FileDescriptor;
LPVOID Buffer;
DWORD ReadCount;
LPDWORD AmountRead;
LPOVERLAPPED Overlapped;
The ReadFile subroutine reads the number of bytes specified by the ReadCount parameter from the FileDescriptor parameter into the buffer indicated by the Buffer parameter. The number of bytes read is saved in the AmountRead parameter. The Overlapped parameter indicates whether or not the operation can be handled asynchronously.
The ReadFile subroutine returns a boolean (an integer) indicating whether or not the request has been completed.
The ReadFile 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 read. |
ReadCount | Specifies the maximum number of bytes to read. |
AmountRead | Specifies the number of bytes read. 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 ReadFile subroutine returns a boolean indicating the request has been completed.
Item | Description |
---|---|
EINPROGRESS | The read 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 read request cannot be immediately satisfied and cannot be handled asynchronously. |
EINVAL | The FileDescriptor parameter is invalid. |
void buffer;
int amount_read;
b = ReadFile (34, &buffer, 128, &amount_read, NULL);
void buffer;
int amount_read;
LPOVERLAPPED overlapped;
b = ReadFile (34, &buffer, 128, &amount_read, overlapped);