Server 用 WSAAsyncSelect 模型,Client给关闭程序时(不进行shutdown与closesocket),
server收不到FD_Close消息,怎么才会自动收到这个消息呢?

解决方案 »

  1.   

    可以在客户端退出时发送一个要求断开连接的数据包
    比如包里的数据包含 DISCONNECT 
      

  2.   


    对方不shutdown或closesocket,你怎么可能及时响应FD_CLOSE消息,开启keepalive
      

  3.   

    保证能及时知道客户端非正常关闭(无法及时响应FD_CLOSE),可以加入心跳包。正常关闭下应当调用shutdown、closesocket
      

  4.   

    msdn 如是说
    the FD_CLOSE is recorded when the connection goes into the TIME WAIT or CLOSE WAIT states. This results from the remote end performing a shutdown on the send side or a closesocket.
      

  5.   

    对方不关闭的话你只能是心跳包或者keepalive自己来检测了