LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP with XML

I'm toying with the idea of sending data over a network using TCP/IP. I've played about the the TCP/IP examples that ship with LabVIEW and so am relatively familiar with the basic operation of the protocol and of the providided LabVIEW functions.

 

One area I haven't found too much information or source code on is the ability to use a markup language like XML with TCP/IP to specify the type of data that is being transmitted. My data source will produce data from different sensors which will have different information (like name of sensor, number of bytes per sensor etc.) that the client will need to parse the data.

 

Can anyone point me to an example or at least somemore information on the subject. I pretty much want to generate and write some header info for the data so the client know what to expect.

 

Strokes

0 Kudos
Message 1 of 4
(3,076 Views)

Hi!

If all you need is to provide XML to clients you could consider using a Web Service(http://www.ni.com/white-paper/7350/en) instead of writing your own server.

 

Regards,

Marco

Message 2 of 4
(3,064 Views)

With TCP, you always transmit strings.  Always.

 

However you can of course flatten anything you would like into a string, send it, and then unflatten it on the other side.

 

XML is usually already a string so you shouldn't have any problems there.  I suspect part of what you're really asking is how do you let the receiving side know how much data to expect.  If you look at those TCP examples in LV you'll see that the always get the size of the string and then send that number over as a U32.  The receving side reads 4 bytes (U32 size) and then reads the number of bytes specified in that U32.

 

From what I've seen this is pretty standard practice.  This allows you to send about any string you want without worry.  Then whatever data you want to send/receive, you just make sure it's a string, send it, and then unflatten or use it directly on the other end.  XML, Doubles, cluster, classes, that's up to you.

Chris
Certified LabVIEW Architect
Certified TestStand Architect
Message 3 of 4
(3,063 Views)

Marco is correct, but do be careful: I have a lot of experience with web services and while you can quickly get them to output XML, if you need it to conform to a certain schema (which I susupect you do) you're going to have to do it all manually which may negate any advantages.

Chris
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 4 of 4
(3,062 Views)