How to check if a socket connection is live in Boost::asio?

前端 未结 2 549
北荒
北荒 2021-01-17 19:46

I\'m using the Boost::asio to implement a client/server applicaion. The client code below is used to connect to the remote server .

   try
    {
        bo         


        
2条回答
  •  时光取名叫无心
    2021-01-17 19:55

    This is a limitation of the underlying socket interface (I think both for Winsock/Bekerly). You could invent a message specifically for this purpose, that the server answers on if it is alive. Else if you get a timeout, means connection is down.

    EDIT: As Joachim pointed out, trying to read the socket might be a better way.

提交回复
热议问题