代码如下:
CMySocket* sockServer;
CListBox m_lstStatus;
           .......
           .......sockServer=new CMySocket(this);
if(sockServer->Create(4000)) 
m_lstStatus.AddString("Creating");
else {
strerr.Format("%i",GetLastError());
m_lstStatus.AddString(strerr); 
      }

解决方案 »

  1.   

    应用程序没有调用WSAStartup, 或者调用WSAStartup失败
      

  2.   

    WSANOTINITIALISED 
    (10093) 
    Successful WSAStartup not yet performed. 
    Either the application has not called WSAStartup or WSAStartup failed. The application may be accessing a socket that the current active task does not own (that is, trying to share a socket between tasks), or WSACleanup has been called too many times. 应该是在你的:
    ...App::InitInstance()
    中添加上: if (!AfxSocketInit())
    {
    AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
    return FALSE;
    }因为要使用Winsock需要初始化,楼上兄弟的说法也正确,那是在SDK编程中初始化的方法,用MFC的话,就使用函数AfxSocketInit()就OK了
      

  3.   

    你创建工程时没有选中winsocket支持
    必须手动添加初始化代码
    #include <afxsock.h>
    AfxSocketInit();