Transmitting serialized data of multiple types and variable length over a socket
Hello, I am new to boost (few months). I have a client - server situation where there can be multiple clients (Linux or Window) connected to one server (Linux). Clients send requests and Server sends response to the clients. Server also sends new updates which the clients will keep receiving. The request /response has following structure: struct Message { uint8_t data_name; uint16_t count_of_data_records; // uint16_t data_len; //length of serialized_data string serialized_data; //serialized_data is binary serialized data using boost serialization. }; We have 6 types of structs (identified by data_name) that are serialized into serialized_data. I understand that I have to send two buffers one (ASCII buffer) with data_name, count_of_data_records and data_len and other binary buffer. I have seen example: http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/serializati... Questions: 1. I am not sure if I should use synchronous or asynchronous communication, I am inclined towards synchronous. 2. What is the best way to send this data across from a server to multiple clients and from one client to one server.I don't know the best way to implement it. Please advise what is the best way or if you know of an example. Regards, Anil Agrawal
A.Agrawal@patrick.com.au wrote:
Questions: 1. I am not sure if I should use synchronous or asynchronous communication, I am inclined towards synchronous.
Asynchronous will scale better than a synchronous solution. In other words, if implemented correctly your asynchronous solution will use less resources than the synchronous solution.
2. What is the best way to send this data across from a server to multiple clients and from one client to one server.I don't know the best way to implement it. Please advise what is the best way or if you know of an example.
I recommend that you take a look at the chat server/client example. It does exactly this type of thing using an asynchronous solution. Good luck. Michael -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com
participants (2)
-
A.Agrawal@patrick.com.au
-
Michael Caisse