[英]How to handle asynchronous socket receiving in C++?
I'm currently using a thread to handle Connect and Send calls asynchronously. 我目前正在使用一个线程来异步处理Connect和Send调用。 This is all working fine, but now I want to make receiving asynchronous too.
这一切都运行正常,但现在我也希望接收异步。 How should I receive data without pausing the whole queue while waiting for data?
在等待数据时如何在不暂停整个队列的情况下接收数据? The only solution I can think of right now is a second thread.
我现在能想到的唯一解决方案是第二个线程。
Look into non-blocking sockets and polling APIs like select(2)
/ poll(2)
/ epoll(4)
/ kqueue(2)
. 查看非阻塞套接字和轮询API,如
select(2)
/ poll(2)
/ epoll(4)
/ kqueue(2)
。
Specifically in C++, look into boost::asio
. 特别是在C ++中,请查看
boost::asio
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.