LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

send 2D-array to server

please tell me how a client must send 2D-array of numeric data via tcp/ip to server, And how a server must receive them?Thank...
0 Kudos
Message 1 of 13
(3,902 Views)
joly,

The type of data really doesn't matter, because all the bytes will ultimately be sent as ASCII characters no matter how it's done. There are many ways to handle this, with the main determining factors being:
- Are you running LabVIEW on both ends (client and server)?
- Do you want to use a higher level (easier to program) method, or a lower level method?

If you're running LabVIEW on both ends, then the easiest thing is probably to use DataSocket. It's easier because it abtracts away the overhead of casting/flattening your data to strings and keeping track of how many bytes are being sent and received. Check out "DS Writer.vi" and "DS Reader.vi" in the Example Finder (Help >> Find Examples, then Networking >> Data Socket >> General).

If you don't want the overhead of DataSocket, then you can use the primitive TCP read and write functions in LabVIEW. To learn how, look at "Simple Data Server.vi" and "Simple Data Client.vi" (in Example Finder under Networking >> TCP & UDP). They are sending a 1D numeric array by casting it to a string first; one wrinkle for you is that you can't use "Type Cast" with a 2D array. So, you would have to replace that primitive with "Flatten to String" instead, and you'd have to replace the Type Cast on the receiving end with "Unflatten from String" that has a dummy 2D numeric array wired into its "type" input.

If you're not using LabVIEW on the receiving end, then you have to write some program in some other language to receive the byte stream that is sent and recast it into an array object in that language. If you have access to a DataSocket API in that other language, then DataSocket is again the way to go. If not, you'll have to avoid DataSocket and build the receiving-end code yourself.

Hope it helps,
John
0 Kudos
Message 2 of 13
(3,888 Views)
Thank you for your answer.I attach with this message two VIs.I want to know if they ara like you describe in your reply. I want to send the number of byte to read brfore sendind 2D-array of data.Hw can I do?
Thank...
0 Kudos
Message 3 of 13
(3,882 Views)
Ihave forgot the second VI...
0 Kudos
Message 4 of 13
(3,882 Views)
joly,

Yes, that's the idea. The main thing you're missing is the part where you check how many bytes long your flattened string is and send that number along first, so that the other end of the transaction knows how many bytes to read. That's important because in general you might not always send an array of the exact same dimensions.

Check the examples and copy that part out if it's not clear. It's where they use String Length and then Type Cast to get that length value (a 4 bytes integer), and then send that along using TCP Write first.

--John
0 Kudos
Message 5 of 13
(3,875 Views)
I would like to have the website of the exemple you are refering to in your mail. Im'attaching a file of client ...is-it good?
0 Kudos
Message 6 of 13
(3,870 Views)
Yes, that's the right way to determine the byte count and send it first.

Check the first reply I gave above to see exactly where the examples I'm referring to can be found--they ship with LabVIEW. You're understanding very well what I'm describing, but it would be much easier for you if you would open up the client and server example pair and examine its code.

If my description above of the Example Finder is unclear, you can also open the VIs from inside your LabVIEW directory: \examples\comm\TCP.llb\Simple Data Server.vi and Simple Data Client.vi.

Hope that's clear,
John
0 Kudos
Message 7 of 13
(3,865 Views)


joly a écrit:
please tell me how a client must send 2D-array of numeric data via tcp/ip to server, And how a server must receive them?Thank...


Good morning,
In my program, I try with those VI but the server do not receive all the data when it is 1D-array and the server receive no data when it is 2D-array...What's happenned?
Thank...
0 Kudos
Message 8 of 13
(3,853 Views)
Good morning,
In my program, I try with those VI but the server do not receive all the data when it is 1D-array and the server receive no data when it is 2D-array...What's happenned?
Thank...
0 Kudos
Message 9 of 13
(3,852 Views)
Good morning,
In my program, I try with those VI but the server do not receive all the data when it is 1D-array and the server receive no data when it is 2D-array...What's happenned?
Thank...
0 Kudos
Message 10 of 13
(3,851 Views)