LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

do I need to specify the string lenght in an application client-server?

I am using tcp/ip; I am programming my application client-server; the server sends data of the e-series board to the client. If I do not specify the string lenght in the server, the application crash.
0 Kudos
Message 1 of 4
(2,936 Views)
Hi Boxer,

Running with the details you have provided, I will assume that you are using the TCP/IP VI's to accomplish the transfer of data. Since the TCP/IP VI's only accept string data types you must be converting the floats you are getting from the E series board to strings some where along the line. If this is correct read on.

The examples that ship with LV illustttrate how to handle the transfer of variable length strings between server and client. This is done by first transfering (from the server) a fixed length byte count. Following the byte count, a variable length string can be transfered. On the client side a fixed number of bytes is read from the TCP/IP connection and this value is then used to specify the number of bytes to read in the subsequent
packet.

If I have gotten close with any of this, please feel free to respond with more details.

Which end is crashing? Client or Host?

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 4
(2,936 Views)
Thank you, so much Ben. I attach my VI (it´s a proof), that is the client. As you can guess, I concatenate the strings in the server and then I send them; in the client I read the values one by one,I want to say: I use TCP Read function five times.
I want to use TCP Read function only once. Is this possible?
Thanks in advance.
0 Kudos
Message 3 of 4
(2,936 Views)
Boxer,

If you write a wrapper for all of the data from the server, then you can read in one pair. The first read will say how many bytes you need to read for all 5 data items. Then read that many bytes. After this, you will need to do a bunch of typecasting and chopping that string up into the pieces of data that are there. This may not be more efficient than what you are doing now, you would have to test.

Randy Hoskin
Applications Engineer
National Instruments
http://www.ni.com/ask
0 Kudos
Message 4 of 4
(2,936 Views)