CSocket ser;
ser.Create(3000);
ser.Listen();为什么打不开端口?什么原因?新手提问!

解决方案 »

  1.   

    楼主对socket理解好像还不够,再看看文档吧。找点例子程序学习一下也好。
      

  2.   

    估计你是缺少了
    BOOL CMyApp::InitInstance()
    {
       //Default Application Wizard code.
       if(!AfxSocketInit())
          AfxMessageBox("Failed to Initialize Sockets",MB_OK| MB_ICONSTOP);
       return CWinApp::InitInstance();
      

  3.   

    首先要初始化
    if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
    {
    return FALSE;
    }
    if (!AfxSocketInit())
    {
    return FALSE;
    }
    其次你Create的时候最好不指定端口,让Windows自己选择一个可用端口