tags:

views:

365

answers:

5

Hi,

Could someone please help and provide me links where I can find materials/examples describing how to exchange data in the form of XML schemas between socket programs written in C/C++?
Actually I have two software tools running in different OSs, in which I coupled with socket programs written in c/c++. As both work with xml, I am looking if there is a simple way to exchange data in the form of xml documents in order to run simulation studies.
Thanks in advance for your replies,

+1  A: 

Obviously, gSOAP contains relevant code, not sure if that's what you're looking for, though.

Michael Krelin - hacker
thanks! That is what I am trying to use , but it is complex
make
A: 

Look at how HTTP does this - simple header that indicates length of the payload that follows, plus some extras like timestamps and types. All you need to tell the other side is how many bytes to read from the socket and maybe the file name. You might also want to implement an acknowledgement back to the sender depending on your application needs.

Nikolai N Fetissov
A: 

the question is how to send xml schema through a socket program written in C/C++ ? here is an exp:

----- xml ---
...
<xs:element name="zone">
<xs:complexType>
<xs:sequence>
<xs:element name="Var_name" type="xs:string"/>
<xs:element name="var_value" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:element>

------ C/C++ ----
...
// send message to server
if (send(csocket, buffer_snd, BUFSIZE, 0) > BUFSIZE)
cout << send() failed << endl;
...

Thanking you in advance for your help,

make
This should be a modification of the question.
tgandrews
+1  A: 

You might consider using an XML parsing library with a streaming parser for this, assuming you can rely on the documents being well-formed on both ends - well-formed XML is self-delimiting. Something like libxml2 should be suitable.

Greg Campbell
A: 

It seems what you want is to specify your protocol in XML Schema and then auto-generate C++ classes that would allow you to parse and serialize the XML messages. If so then you may want to take a look at CodeSynthesis XSD which is an XML Schema to C++ compiler. It does pretty much exactly what you are looking for. If you want a more lighter-weight version, there is also XSD/e which is geared more towards mobile/embedded development.

Boris Kolpackov
Thanks a lot for the answer, that is great
make