I've been playing around with Boost::Asio and checking out it's capability when it comes to n independent users collaborating to compute a function on shared inputs.
At one point I need to get each user to send to (resp. receive from) all the other users some data.
I guess effectively I'm looking for "active" establishment by each user opposed to the common client-server examples seen all over the internet.
I've got working code that allows a user to send data to another user. I'm having trouble seeing how I should get all users to be simultaneously sending and receiving from each other. I also can't seem to generalise multiple async_connects
at once.
Are there any suggestions as to how this sort of protocol should be implemented? Should I be looking at using threads to manage both sending and receiving?
If you on Unix-based OS, such as Linux, I would start with much less complex solution using C
programming language (or C++
if you need that), but without using Boost
library. Just use plain old select
syscall instead. See manpage and tutorial manpage .
Only after that I'd switch to something fancy like Boost
.
See also this tutorial about BSD sockets programming.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.