CSshClient::Peek Method  
 
INT Peek(
  LPBYTE lpBuffer,  
  INT cbBuffer  
);
INT Peek(
  CString& strBuffer,  
  INT cbBuffer  
);

The Peek method reads the specified number of bytes from the server and copies them into the buffer, but it does not remove the data from the internal receive buffer. The data may be of any type, and is not terminated with a null character.

Parameters

lpBuffer
Pointer to the buffer in which the data will be copied. An alternate form of this method allows a CString variable to be passed and data read from the socket will be returned in that string.
cbBuffer
The maximum number of bytes to read and copy into the specified buffer. This value must be greater than zero.

Return Value

If the method succeeds, the return value is the number of bytes actually read. A return value of zero indicates that the server has closed the connection and there is no more data available to be read. If the method fails, the return value is SSH_ERROR. To get extended error information, call GetLastError.

Remarks

The Peek method can be used to examine the data that is available to be read from the internal receive buffer. If there is no data in the receive buffer at that time, a value of zero is returned. It should be noted that this differs from the Read method, where a return value of zero indicates that there is no more data available to be read and the connection has been closed. The Peek method will never cause the client to block, and so may be safely used with asynchronous connections.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: cstshv11.lib

See Also

IsBlocking, IsReadable, Read, ReadLine, Write, WriteLine