[Serialization] Are the serialized char* different when code runs in 32/64 bits machines ?

Hi, I use the Bost serialization library to serialize some classes that I put in a char* variable ... I have a Server which publish this char* variable and Clients get this variable and de-serialize it to obtain the original class... Everything work fine when servers and clients are running in machines with the same architecture (64 or 32 bits)... But when I run the server in a 64 bits machine, the char* variable is not recognized in a 32 bits client. In this code: std::stringstream is; is.rdbuf()->pubsetbuf(c, m_StringSize); boost::archive::binary_iarchive *ia = new boost::archive::binary_iarchive(is); The last line returns the std::exception: "invalid signature" To be sure that I am not doing something wrong I printed the first 80 characters of this variable when it is created in a 64 bits server and a 32 bits server: In a 64 bits machine server, the print out is: "........serialization::archive.................MonH1F............Efficiency.(cou" (the "." are not printable ascii characters) in Hexa format it is : 16 00 00 00 00 00 00 00 73 65 72 69 61 6C 69 7A 61 74 69 6F 6E 3A 3A 61 72 63 68 69 76 65 04 04 08 04 08 01 00 00 00 06 00 00 00 00 00 00 00 4D 6F 6E 48 31 46 00 00 00 00 1E 00 00 00 00 00 00 00 45 66 66 69 63 69 65 6E 63 79 20 28 63 6F 75 And ind the case of a 32 bits machine server, it is: "....serialization::archive.............MonH1F........Efficiency.(counter2/counte" 16 00 00 00 73 65 72 69 61 6C 69 7A 61 74 69 6F 6E 3A 3A 61 72 63 68 69 76 65 04 04 04 04 08 01 00 00 00 06 00 00 00 4D 6F 6E 48 31 46 00 00 00 00 1E 00 00 00 45 66 66 69 63 69 65 6E 63 79 20 28 63 6F 75 6E 74 65 72 32 2F 63 6F 75 6E 74 65 They are similar but not equal... Thank you, very much Juan Otalora _________________________________________________________________ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

jotalo jotalo wrote:
Hi, I use the Bost serialization library to serialize some classes that I put in a char* variable ... I have a Server which publish this char* variable and Clients get this variable and de-serialize it to obtain the original class...
Everything work fine when servers and clients are running in machines with the same architecture (64 or 32 bits)...
But when I run the server in a 64 bits machine, the char* variable is not recognized in a 32 bits client. In this code: std::stringstream is; is.rdbuf()->pubsetbuf(c, m_StringSize); boost::archive::binary_iarchive *ia = new boost::archive::binary_iarchive(is);
The last line returns the std::exception: "invalid signature"
To be sure that I am not doing something wrong I printed the first 80 characters of this variable when it is created in a 64 bits server and a 32 bits server:
In a 64 bits machine server, the print out is:
"........serialization::archive.................MonH1F............Efficiency.(cou" (the "." are not printable ascii characters)
in Hexa format it is :
16 00 00 00 00 00 00 00 73 65 72 69 61 6C 69 7A 61 74 69 6F 6E 3A 3A 61 72 63 68 69 76 65 04 04 08 04 08 01 00 00 00 06 00 00 00 00 00 00 00 4D 6F 6E 48 31 46 00 00 00 00 1E 00 00 00 00 00 00 00 45 66 66 69 63 69 65 6E 63 79 20 28 63 6F 75
And ind the case of a 32 bits machine server, it is:
"....serialization::archive.............MonH1F........Efficiency.(counter2/counte"
16 00 00 00 73 65 72 69 61 6C 69 7A 61 74 69 6F 6E 3A 3A 61 72 63 68 69 76 65 04 04 04 04 08 01 00 00 00 06 00 00 00 4D 6F 6E 48 31 46 00 00 00 00 1E 00 00 00 45 66 66 69 63 69 65 6E 63 79 20 28 63 6F 75 6E 74 65 72 32 2F 63 6F 75 6E 74 65
They are similar but not equal...
It's pretty clear here that the 64-bit machine is using a 64-bit length and 32-bit machine is using a 32-bit length. Can you share the source of the function(s) you are using to serialize/deserialize that data? -- Jon Biggar Floorboard Software jon@floorboard.com jon@biggar.org

On Sun, 31 Aug 2008, jotalo jotalo wrote:
Hi, I use the Bost serialization library to serialize some classes that I put in a char* variable ... I have a Server which publish this char* variable and Clients get this variable and de-serialize it to obtain the original class...
You might wanna at look Boost Asio serialization examples. http://www.boost.org/doc/libs/1_36_0/doc/html/boost_asio/examples.html -V

binary_archives are not portable accross machine architectures. Robert Ramey

binary_archives are not portable accross machine architectures. Yes..And it looks like the text_archives are portable because when I changed to text_archives it worked fine... I dont know if I can use it because the new variables are bigger....but at least it is an alternative method... Thank you jotalo
_________________________________________________________________ Connect to the next generation of MSN Messenger http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
participants (4)
-
Jonathan Biggar
-
jotalo jotalo
-
Robert Ramey
-
Vjekoslav Brajkovic