我写了一个客户端和服务器端,客户端发到服务器端的信息,服务器端能够收到,但是服务器端发给客户端的信息,客户端就是收不到,这是怎么回事?  
客户端接受的代码:  
void  CClientSocket::OnReceive(int  nErrorCode)    
{  
           //  TODO:  Add  your  specialized  code  here  and/or  call  the  base  class  
           char  buff[17];  
           int  bufflen=17;  
           Receive(buff,bufflen);  
 
           AfxMessageBox(buff);  
 
           CSocket::OnReceive(nErrorCode);  
}  
设了个断点,根本就运行不到这里,弄了两天了,都不知道怎么办?都凌晨一点了,帮帮忙,看看是什么原因会这样的,客户端和服务器端的Socket都是继承CAsynSocket. 
服务器端发送的代码是在服务器端接收到客户端的消息后发送:
void CReceiveSocket::OnReceive(int nErrorCode) 
{
// TODO: Add your specialized code here and/or call the base class
char buff[17];
int bufflen=17;
Receive(buff,bufflen);
AfxMessageBox(buff);

Send(buff,bufflen);

CAsyncSocket::OnReceive(nErrorCode);
}

解决方案 »

  1.   

    CAsynSocket需要指定一个接收消息的窗体,否则无法响应收到网络信息的事件。
      

  2.   

    将完整的代码传给我
    [email protected]
      

  3.   

    AsyncSelect(FD_WRITE);
    void  CClientSocket::OnReceive(int  nErrorCode)    
    {  
               //  TODO:  Add  your  specialized  code  here  and/or  call  the  base  class  
               char  buff[17];  
               int  bufflen=17;  
               Receive(buff,bufflen);  
              AsyncSelect(FD_WRITE);
      
         AfxMessageBox(buff);  //有问题,CWinApp* pApp=(CWinApp*)AfxGetApp();  
               CSocket::OnReceive(nErrorCode);  
    }  
      

  4.   

    看一下这篇文章你全明白了:
    http://www.yesky.com/SoftChannel/72342371928702976/20040521/1800089.shtml