How to check if socket is closed in Boost.Asio?

后端 未结 6 1782
难免孤独
难免孤独 2020-12-11 04:17

What is the easiest way to check if a socket was closed on the remote side of the connection? socket::is_open() returns true even if it is closed on the remote

6条回答
  •  时光取名叫无心
    2020-12-11 04:51

    Is there a boost peek function available? Most socket implementations have a way to read data without removing it from the queue, so you can read it again later. This would seem to satisfy your requirements.

    After quickly glancing through the asio docs, I wasn't able to find exactly what I was expecting, but that doesn't mean its not there.

    I'd suggest this for starters.

提交回复
热议问题