请问CSocket 类中的 OnReceive()的参数

来源:百度知道 编辑:UC知道 时间:2024/05/25 01:28:24

CAsyncSocket::OnReceive
Called by the framework to notify this socket that there is data in the buffer that can be retrieved by calling the Receive member function.

virtual void OnReceive(
int nErrorCode
);
Parameters
nErrorCode
The most recent error on a socket. The following error codes apply to the OnReceive member function:
0 The function executed successfully.
WSAENETDOWN The Windows Sockets implementation detected that the network subsystem failed.
Remarks
For more information, see Windows Sockets: Socket Notifications.

Example
void CMyAsyncSocket::OnReceive(int nErrorCode) // CMyAsyncSocket is
// derived from CAsyncSocket
{
static int i=0;

i++;

TCHAR buff[4096];
int nRead;
nRead = Receive(buff, 4096);

switch (nRead)
{
case 0:
Close()