Re: [asio-users] Concurent async_read and async_write
Brought to you by:
chris_kohlhoff
From: Roger A. <Ro...@wa...> - 2008-01-21 00:43:35
|
Take a look at the chat server and client in the asio examples. Note the use of a queue for async_writes. This is because it is not safe to issue async_write before the previous async_write has completed (the data could get interleaved if async_write needs more than one call to async_write_some to push the data on to the tcp stack). Presumably the same is true of async_read, but the typical design is to allow each async_read to complete and be handled before issuing the next (achieved by issuing the next read from the read handler itself) so the problem does not arise. -----Original Message----- From: asi...@li... [mailto:asi...@li...] On Behalf Of KRUCHIO Gabor Sent: Saturday, 19 January 2008 8:47 AM To: 'asi...@li...' Subject: [asio-users] Concurent async_read and async_write Hi, I am facig to the following problem:=20 - server process waits for a client to connect on socket_A; - client_A connects on socket_A to server; - after establishing tcp connection successfully, both client_A and the server can send concurently messages to the opposite side, After studying asio examples and changing serialisation example code, my client - server is able to play request-response scenario, i.e.: - after receiving a request server sends back a response to client_A ( i.e. in server: async_write() after async read() ) or - after accepting connection server sends a request to client_A and client_A responds to the server ( i.e. in server async_read() after async_write() ). Please give me some guides or pointers how to send messages thru tcp using asio from server to client_A while concurently server waits for messages from clientA on the *same* socket. Regards: Gabor ------------------------------------------------------------------------ - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ asio-users mailing list asi...@li... https://lists.sourceforge.net/lists/listinfo/asio-users The information contained in this e-mail is likely to be confidential and may be legally privileged. It is intended only for the addressee. If you have received this message in error please notify the sender immediately at the above address. The disclosure, copying or distribution of this message or its contents without the prior approval of Wallingford Software is strictly prohibited. Wallingford Software is not liable for unauthorised disclosures nor for subsequent actions or omissions in reliance upon them. Registered in the UK, company no: 02288719 Wallingford Software Limited, Howbery Park, Wallingford, Oxfordshire, OX10 8BA |