如题,先谢各位了

解决方案 »

  1.   

    我用c++builder作服务器,vb作客户端没有问题,你的也应该没有问题。
    你再看一看,或者贴出代码。
      

  2.   

    void CMyServerSocket::OnAccept(int nErrorCode) 
    {
    // TODO: Add your specialized code here and/or call the base class

    //CAsyncSocket::OnAccept(nErrorCode);
    //侦听到连接请求,调用Accept函数
    CNewSocket* pSocket = new CNewSocket( );
    //Accept( m_pSocket );
    if ( Accept( *pSocket ) ) {
    pSocket->AsyncSelect( FD_READ );
    //m_pSocket.AsyncSelect( FD_READ );
    m_pSocket=pSocket;
    }
    else
    delete pSocket;
    }
    void CNewSocket::OnReceive(int nErrorCode) 
    {
    // TODO: Add your specialized code here and/or call the base class
    m_nLength=Receive(m_szBuffer,sizeof(m_szBuffer),0 );
    // 直接转发消息
    AsyncSelect(FD_WRITE);
    m_szBuffer[ m_nLength ] = '\0';
    AfxMessageBox( m_szBuffer );

    //CAsyncSocket::OnReceive(nErrorCode);
    }void CNewSocket::OnSend(int nErrorCode) 
    {
    // TODO: Add your specialized code here and/or call the base class
    Send( "lxh,00000000138180395",strlen( "lxh,00000000138180395" ),0);
    //CAsyncSocket::OnSend(nErrorCode);
    }