Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use the same boost::asio::io_service for multiple listening sockets?

I am using Boost asio 1.48. Is it possible to re-use a single boost::asio::io_service instance for multiple listening sockets that are open simultaneously?

The docs say its share-safe, but I am not sure if that is already a positive answer.

like image 926
Erik Avatar asked Jan 28 '12 23:01

Erik


1 Answers

Yes, you can, and you should. And you can use that same io_service to handle those sockets, handle timers, handle requests you post to it, and so on. The whole point of an io_service is to act as a central dispatcher for work of all kinds.

like image 123
David Schwartz Avatar answered Sep 21 '22 06:09

David Schwartz