简体   繁体   English

我可以为多个侦听套接字使用相同的boost :: asio :: io_service吗?

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

I am using Boost asio 1.48. 我正在使用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? 是否可以为同时打开的多个侦听套接字重用单个boost::asio::io_service实例?

The docs say its share-safe, but I am not sure if that is already a positive answer. 文档说它的共享安全,但我不确定这是否已经是一个肯定的答案。

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. 并且您可以使用相同的io_service来处理这些套接字,处理定时器,处理post给它的请求,等等。 The whole point of an io_service is to act as a central dispatcher for work of all kinds. io_service是充当各种工作的中央调度员。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM