Boost::asio - how to interrupt a blocked tcp server thread?

后端 未结 5 530
野的像风
野的像风 2020-11-30 04:17

I\'m working on a multithreaded application in which one thread acts as a tcp server which receives commands from a client. The thread uses a Boost socket and acceptor to w

5条回答
  •  清歌不尽
    2020-11-30 04:40

    When you receive an event that it's time to exit, you can call acceptor.cancel(), which will cancel the pending accept (with an error code of operation_canceled). On some systems, you might also have to close() the acceptor as well to be safe.

提交回复
热议问题