[英]How to make boost::asio::ip::tcp::acceptor block forever?
How would someone do that? 有人会怎么做? It just blocks until the first connection attempt.
它只是阻塞直到第一次连接尝试。
I don't think you can, accept
will block until the first connection arrives and async_accept
won't block at all (and will only handle the first connection as well). 我认为您可以
accept
, accept
会阻塞直到第一个连接到达,而async_accept
根本不会阻塞(并且也只会处理第一个连接)。 However, why do you want this? 但是,为什么要这样? You can always initiate another
accept
once the previous one returned. 一旦前一个
accept
返回,您始终可以发起另一个accept
。 It's not like you'd miss anything since accept
only removes theses connections from the listening sockets queue . 好像您不会错过任何事情,因为
accept
只从侦听套接字队列中删除这些连接。
boost::asio::ip::tcp::acceptor::accept
方法已经阻塞,直到尝试连接为止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.