There are lots of ways to serialize data. In your case you could simply send the comma-delimited data as a single string and parse that at the receiver side.
On Tue, Sep 17, 2013 at 6:27 PM, Riskybiz <[email protected]> wrote: > So, I’ve got a working implementation of a zeromq REQ-REP socket pattern and > am using it to pass data in the form of character strings between a server > and several clients, like so: > > Sample comma separated data strings sent as a multipart message (of several > thousand parts), each line is a complete instruction for the client to draw > something on screen: > > > > 414,2095,@ESU13,upper,1,1,41528.600694,41528.602778,1679.75000,1679.75000,16776960,3,0,1 > > 415,2095,@ESU13,lower,1,1,41528.600694,41528.602778,1679.50000,1679.50000,16776960,3,0,1 > > 416,2095,@ESU13,marker,1,1,41528.602778,41528.602778,1679.75000,1680.50000,16776960,3,0,0 > > 417,2095,@ESU13,rectangle,1,1,41528.600694,41528.603472,1679.75000,1679.50000,65535,0,0,1 > > 418,2095,@ESU13,label,1,1,41528.600694,1679.50000,ID:2095 0.0149% 5Bars 100D > 3.00IR,Arial,5.00000,0,0 > > > > My issue is that each of the data strings has to be composed at the server > and then decoded at the client end to extract the data; this works but is > not very elegant, I’m sure there is a better and more efficient way……… > > > > I have the notion that I’d like to try encapsulating each line of the data > to be sent in a custom class object object instance; then serialize each > object, pass it through the REQ-REP sockets and deserialise to reconstruct > the object at the client end. The simple class would be in the format like > so; only comprising data members. > > > > class Instruction > > { > > public: > > //Constructor > > Instruction(const unsigned int &intData, const double &dblData, const > std::string &strData): IntData(intData), DblData(dblData), StrData(strData) > > { > > } > > > > //Data Members > > const unsigned int IntData; > > const double DblData; > > const std::string StrData; > > };//class > > > > Trouble is I don’t know how to implement this practically. Is anyone able > to provide a simple example of how to accomplish serialising and > deserialising a custom object and sending it though a REQ-REP socket pair? > Or does anyone know of a good online tutorial on this subject? I’m working > with Visual Studio 2012 Express in C++. > > > > With very many thanks, > > > > Riskybiz. > > > > > > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
