Hi, I am thinking how to use ASIO for my specific situation. Well, I'll try to explain: I have a client that is connected to multiple remote daemons. Now the client can initiate alternating "start" and "stop" messages to it's daemons like this: * send a "start" message to all daemons * send a "stop" message to all the daemons * send a "start" message to all the daemons * send a "stop" message to all daemons etc I want to be able to have multiple threads sending a "start" or a "stop" to all connected daemons using boost::asio::async_write(). But this has to be in phases, so all threads handling a "start" should finish first before a "stop" can be initiated. I was wondering if this is solvable using ASIO and if so, hopefully somebody can point me in the right direction. Cheers, Andrej __________________________________________________________ Sent from Yahoo! Mail. A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
I want to be able to have multiple threads sending a "start" or a "stop" to all connected daemons using boost::asio::async_write(). But this has to be in phases, so all threads handling a "start" should finish first before a "stop" can be initiated.
I'm not sure I understand your question correctly: do you wish to send these messages to the *same* socket from *multiple* threads? Or one daemon is served by one socket and one thread? Anyway, you have to be aware of an important point: after you issued async_XXX call, you should wait until it's complete before you can issue another async. call of that type. Eg., if you've called async_write(), then you may issue another async_write() not before the completion handler of the 1st one is called (see asio examples for details). Besides, if you'd like to send messages from different threads, you can just post your message, using io_service::post(), so that you avoid messing with explicit synchronization. See chat_client example: http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/example/chat/chat_c...
participants (2)
-
Andrej van der Zee
-
Igor R