将unsigned long aa=GetLastError();
改成int aa=GetLastError();
试试

解决方案 »

  1.   

    不行呀,大哥,Create()就出错,而且该成int还是一个样
      

  2.   

    Nonzero if the function is successful; otherwise 0, and a specific error code can be retrieved by calling GetLastError
    上面这行是MSDN关于CSOCKET 中CREATE方法返回值的说明,你的程序运行成功了,当然得到的错误是0了。
      

  3.   

    没有Create()的三个参数无需协议,分别是端口号,通信模式(SOCK_STREAM)和地址
      

  4.   

    不对呀Create()若成功就不会到GetLastError()去了
      

  5.   

    这位大哥大意了,创建成功返回了
    if(sockClient.Create())
    应该改为
    if(!sockClient.Create())
      

  6.   

    GetLastError()得到的是最近一次错误的值,如果你的Create()函数执行成功的话,GetLastError()的返回值是你前一次错误的值,和你的Create()函数无关!