Reputation: 8519
I'm currently using a thread to handle Connect and Send calls asynchronously. 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.
Upvotes: 6
Views: 31103
Reputation: 40548
Depending on what you're doing, non-blocking I/O with select may be the answer.
Upvotes: 2
Reputation: 84151
Look into non-blocking sockets and polling APIs like select(2)
/poll(2)
/epoll(4)
/kqueue(2)
.
Specifically in C++, look into boost::asio
.
Upvotes: 8