在stdafx.h 中加#include <afxsock.h> // MFC socket extensions在app类中加
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}

解决方案 »

  1.   

    在initinstance() 部分,加入下列语句。
    socket在使用前一定要初始化的。
    同时加入#include "stdafx.h"。
             
    if (!AfxSocketInit())
    {
    AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
    return FALSE;
    }
      

  2.   

    try as follow:Stdafx.h中
    #include <afxsock.h>在资源中加入字符串:
    ID: IDP_SOCKETS_INIT_FAILED
    Caption:Windows 通信端口初始化失败。在C***App.cpp中
    BOOL C***App::InitInstance()
    {
    //起始位置加入下面的语句
    if (!AfxSocketInit())
    {
    AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
    return FALSE;
    }
    }