void CClientDlg::OnOK() 
{
// TODO: Add extra validation here
if(!m_Socket.Create())
{
AfxMessageBox("NO......");
return;}
//CDialog::OnOK();
}

解决方案 »

  1.   

    void CClientDlg::OnOK() 
    {
        // TODO: Add extra validation here
            if(m_Socket.Create(port)=SOCK_ERROR)
        {
            AfxMessageBox("NO......");
            return;}
        //CDialog::OnOK();
    }  
    程序作为服务器的话要给出端口参数port
      

  2.   

    明白了
    在CWinApp::InitInstance()
    添加
    AfxSockInit()一句即可
      

  3.   

    to:happymeng(晓梦)
    确实少了AfxSocketInit()
    但是有错误:
    warning C4651: '/D_AFXDLL' specified for precompiled header but not for
    C:\unzipped\CCCC\CCCC.cpp(46) : error C2065: 'IDP_SOCKETS_INIT_FAILED' 
      

  4.   

    在工程里添加组件,
    添加vc控件->  添加Socket支持->搞定!!!
      

  5.   

    在MFC Wizard  setp 3选择Windows socket支持,
    就是#include 
      

  6.   

    加AfxSocketInit()
    #include "AFXSOCK.H"
      

  7.   

    确实少了AfxSocketInit()
    但是有错误:
    warning C4651: '/D_AFXDLL' specified for precompiled header but not for
    C:\unzipped\CCCC\CCCC.cpp(46) : error C2065: 'IDP_SOCKETS_INIT_FAILED' 
      

  8.   

    作为客户端:
    {
    .
    .
    .
    m_Socket.Create();
    m_Socket.Connect(主机IP地址,端口号);
    .
    }
      

  9.   

    什么时候出的错误,详细指出
    我的mail [email protected]