Boost logo

Boost Users :

Subject: [Boost-users] Best method for making synchronous call from async handler
From: David Daeschler (david.daeschler_at_[hidden])
Date: 2010-08-22 22:52:05

Good evening,

Currently I have an application running on boost asio working very well. To
simplify the heck out of it, it takes requests via tcp and passes back
binary information stored on disk. However, I now need to add an extra step
to processing. If the data is not available on the local disk, the server
needs to contact one or more peer servers it knows about, send a query to
each one via UDP asking if it has the data, and then use an existing TCP
connection to that server to retrieve the asset. This step must be
completed before any more processing can be done for the current client even
though the client may be sending even more requests while we process.

My question is, what is the best method for me to achieve the goal? Should
I set up another io_service for the UDP query step along with retrieving the
data from the other server? Is there a good wait to wait on that io_service
to complete? Also in the case that one of the servers has gone away, can I
use a deadline timer to cancel the UDP recvfrom if I don't get a response in
time from one or more servers? I should also probably keep this second
io_service alive throughout the lifetime of the application?

Thank you in advance for advice on tackling this problem the right way with

David Daeschler

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at