|
INT Peek( |
|
SOCKET hSocket, |
|
|
LPBYTE lpBuffer, |
|
|
INT cbBuffer |
|
); |
INT Peek( |
|
LPBYTE lpBuffer, |
|
|
INT cbBuffer |
|
); |
Read data from the client without removing it from the
socket buffer.
Parameters
- hSocket
- An optional parameter that specifies the handle to the client socket.
If this parameter is omitted, the socket handle for the active
client session will be used. If this method is called outside of a
server event handler, the socket handle must be specified.
- lpBuffer
- Pointer to the buffer in which the data will be stored. This
argument may be NULL, in which case no data is copied from the
socket buffers, however the function will return the number of bytes
available to read.
- cbBuffer
- The maximum number of bytes to read and copy into the specified
buffer. If the lpBuffer parameter is not NULL, this value
must be greater than zero.
Return Value
If the function succeeds, the return value is the number of bytes
available to read from the socket. A return value of zero indicates
that there is no data available to read at that time. If the function
fails, the return value is INET_ERROR. To get extended error
information, call GetLastError.
Remarks
The Peek method returns data that is available to read from
the socket, up to the number of bytes specified. The data returned by
this method is not removed from the socket buffers. It must be
consumed by a subsequent call to the Read method. The return
value indicates the number of bytes that can be read in a single
operation, up to the specified buffer size. However, it is important
to note that it may not indicate the total amount of data available
to be read from the socket at that time.
If no data is available to be read, the method will return a value
of zero. To determine if
there is data available to be read, use the IsReadable method.
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header: Include cswsock10.h
Import Library: cswskv10.lib
See Also
IsReadable,
IsWritable,
Read,
ReadLine,
Write,
WriteLine
|
|