本帖最后由 VisualEleven 于 2011-02-25 15:15:46 编辑

解决方案 »

  1.   

     这里“if(nRet == SOCKET_ERROR)err = WSAGetLastError();”如果连接错误就得到WSAGetLastError(),下面应该是如果连接正确就进行数据处理对吧?条件该怎么写呢?SOCKET_ERROR,网上没查到这个的资料!
      

  2.   

    参考MSDN,recv()的说明
    If no error occurs, recv returns the number of bytes received and the buffer pointed to by the buf parameter will contain this data received. If the connection has been gracefully closed, the return value is zero.Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.
      

  3.   

    如果没有错误发生,recv返回收到的字节数和所指向的缓冲区buf的参数将包含此接收数据。如果连接已正常关闭,则返回值为零。 否则,将返回SOCKET_ERROR值,和一个特定的错误代码可通过调用WSAGetLastError检索。 
    再问下,那我如何根据我写的协议对数据进行二次处理呢?
      

  4.   

    本帖最后由 VisualEleven 于 2011-02-25 15:37:48 编辑