Sending struct via Socket using JAVA and C++

byte, c++, java, sockets

Solution

Try using Google's protocol buffers, hosted at the ProtocolBuffers page at Google Code. Small, efficient, python, Java, and C++ support. Sounds like it suits your needs well.

Less overhead than an XML approach, and better than rolling your own - it's harder than you'd think.

Problem

I have a socket where server is in JAVA but Client is in C++. ``` Struct{ float length; char[] name; }myStruct; ``` How can I convert the structures to a byte stream sent by Server and can be correctly parsed by Client? Any sample code would help! (I heard XML is an option but I am not familiar with it ) Thanks.

Original source