我写一个客户端连接 在DOC 里面有 SOCKET类 指针 pSock
在onnewdocument 里面使用
pSock=new CMySocket();
在调用
pSock->Create();
的时候会失败
为什么啊  帮帮忙

解决方案 »

  1.   

    WORD wVersionRequested;
    WSADATA wsaData;
    int err;
     
    wVersionRequested = MAKEWORD( 2, 2 );
     
    err = WSAStartup( wVersionRequested, &wsaData );
    if ( err != 0 ) {
        /* Tell the user that we could not find a usable */
        /* WinSock DLL.                                  */
        return;
    }
     
    /* Confirm that the WinSock DLL supports 2.2.*/
    /* Note that if the DLL supports versions greater    */
    /* than 2.2 in addition to 2.2, it will still return */
    /* 2.2 in wVersion since that is the version we      */
    /* requested.                                        */
     
    if ( LOBYTE( wsaData.wVersion ) != 2 ||
            HIBYTE( wsaData.wVersion ) != 2 ) {
        /* Tell the user that we could not find a usable */
        /* WinSock DLL.                                  */
        WSACleanup( );
        return; 
    }
     
    /* The WinSock DLL is acceptable. Proceed. */
      

  2.   

    当然要初始化,可以用AfxSocketInit()