我现在用到的是一个阻塞、同步方式下的TCP连接,
WSAsyncSeclect是在异步下检测网络事件的,
那么我在同步方式下该如何检测网络连接是否已经断开??

解决方案 »

  1.   

    如果你的程序阻塞在recv上,网络中断它会返回-1,然后用WSAGetLastError看看详细中断原因
      

  2.   

    If no error occurs, recv returns the number of bytes 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.   

    bomdy() ( ) 信誉:99    
    说的已经很详细了
    就这么整吧
      

  4.   

    If no error occurs, recv returns the number of bytes 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