|
Boost Users : |
Subject: [Boost-users] [boost.asio] Concurrently Ping 1000+ Hosts
From: Kyle Ketterer (reminisc3_at_[hidden])
Date: 2013-12-18 17:12:35
Hello,
So the subject line pretty much says it all. Basically, I am trying to
expand off of the icmp ping example given by the boost library
documentation. I would like to ping 1000+ hosts in say, a matter of minutes
rather than a matter of hours.
I have already expanded the class shown here:
http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/example/icmp/ping.cpp
Before I start posting code, I would like to discuss the strategy of trying
to do this.
In my Main thread, I was thinking about creating a vector of PingX objects.
In the PingX class, I would have a separate io_service as well as wrap the
async() functions in strands. I set the deadline timer at 800ms that way
the io_service should return in less than a second. I would then call
io_service run() in separate threads to *concurrently* ping these hosts.
The problem appears to be that even through the async handers are wrapped
in strands, there is data corruption. Is it true that when async handlers
are wrapped in strands, they still cannot be executed *concurrently* ? My
understanding of strand was that it serializes the handler functions to
allow for thread safe access. However, I think that because I am accessing
the same resources in multiple threads (such as the socket() object ), it
is corrupting my expected output as well as occasionally throwing some
exceptions.
Are there any suggestions for the logic surrounding this or if this can be
done in a multithreaded environment?
Thanks!
-- Kyle Ketterer
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net