Jump to content

  • Log In with Google      Sign In   
  • Create Account


Binary Data with boost::asio?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 P@u1   Members   -  Reputation: 100

Like
0Likes
Like

Posted 12 June 2011 - 09:39 AM

Hi everyone,



I just read some of the tutorials of boost::asio and also had a short look into the reference.

In the tutorials only chars are sent.

I am wondering about how it works with binary data. Ofcourse you can convert an 4-byte int into 4 chars, but then you will have problems with endianess.

Is there a good way to send and receive binary data with boost::asio which works platform independently?

Do I maybe need to write my own conversions functions which handle endianess?

Sponsor:

#2 frob   Moderators   -  Reputation: 20500

Like
0Likes
Like

Posted 12 June 2011 - 10:26 AM

Hi everyone,



I just read some of the tutorials of boost::asio and also had a short look into the reference.

In the tutorials only chars are sent.

I am wondering about how it works with binary data. Ofcourse you can convert an 4-byte int into 4 chars, but then you will have problems with endianess.

Is there a good way to send and receive binary data with boost::asio which works platform independently?

Do I maybe need to write my own conversions functions which handle endianess?

It sends binary data, but treats it as char blocks.

You need to serialize your data into something that you can send, and then deserialize it on the other end. Here is some reading to get you started.


Check out my personal indie blog at bryanwagstaff.com.

#3 AllEightUp   Moderators   -  Reputation: 4195

Like
0Likes
Like

Posted 12 June 2011 - 10:41 AM

As frob says, it works fine with binary data but I would suggest looking at Google Protocol Buffers (http://code.google.com/apis/protocolbuffers/) as a very good starting point. Boost serialization is acceptable of course but the protocol buffers are designed specifically for the job and are faster than the Boost serialization system. Admittedly it takes a bit more to integrate into the build pipeline but it is worth the effort.

#4 wood_brian   Banned   -  Reputation: 197

Like
-2Likes
Like

Posted 12 June 2011 - 05:17 PM

Hi everyone,



I just read some of the tutorials of boost::asio and also had a short look into the reference.

In the tutorials only chars are sent.

I am wondering about how it works with binary data. Ofcourse you can convert an 4-byte int into 4 chars, but then you will have problems with endianess.

Is there a good way to send and receive binary data with boost::asio which works platform independently?

Do I maybe need to write my own conversions functions which handle endianess?



I'm working on an on line approach to marshalling C++ objects called the C++ Middleware Writer.
I'm looking for people interested in using the C++ Middleware Writer and am willing to donate 18 hours/week for six months to a project that uses the C++ Middleware Writer. In addition, I'm offering a referral bonus of $175/month for four months if you refer someone to me who I end up working with.


Brian Wood
Ebenezer Enterprises
http://webEbenezer.net




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS