简体   繁体   English

如何使boost :: asio :: ip :: tcp :: acceptor永远永久?

[英]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). 我认为您可以acceptaccept会阻塞直到第一个连接到达,而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.

相关问题 boost :: asio :: ip :: tcp :: acceptor上的分段错误 - Segmentation fault on boost::asio::ip::tcp::acceptor boost :: asio :: ip :: tcp :: acceptor如何与TCP_DEFER_ACCEPT和TCP_FASTOPEN一起使用 - How boost::asio::ip::tcp::acceptor work with TCP_DEFER_ACCEPT and TCP_FASTOPEN Boost-asio在单个(TCP)接收器上侦听多个IP地址 - Boost-asio listening to multiple IP Addresses on a single (TCP) acceptor 提升Asio tcp :: acceptor访问冲突异常 - Boost Asio tcp::acceptor access violation exception boost::asio::ip::tcp::resolver::resolve() 永远阻塞 - boost::asio::ip::tcp::resolver::resolve() blocks forever C++ boost::asio::ip::tcp::acceptor 有时不接受连接器? - C++ boost::asio::ip::tcp::acceptor sometimes doesn't accept connector? boost::asio::ip::tcp::acceptor 在使用 async_accept 接收连接请求时终止应用程序 - boost::asio::ip::tcp::acceptor terminates application when receiving connection request using async_accept 从TCP迁移到udp时,“ acceptor”不是“ boost :: asio :: ip :: udp”的成员 - ‘acceptor’ is not a member of ‘boost::asio::ip::udp’ while migration from tcp to udp 如何接受 boost::asio::ssl::stream<boost::asio::ip::tcp::socket> 作为 boost::asio::ip::tcp::socket 类型的参数 - How to accept boost::asio::ssl::stream<boost::asio::ip::tcp::socket> as an argument of type boost::asio::ip::tcp::socket 提升 asio tcp ip 写入 - boost asio tcp ip write
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM