LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP examples

Hi!
There is an example about TCP/IP I don't understand very well, it is called TCP Communicator- ACtive.vi.
It's in 'Find Examples' in the main menu of Labview. In this example there are three while loops. The reading loop
is clear but i don't understand why two loops are needed to write in TCP. I thougt, it could work with only one,
but it doesn't. I don't understand the inside loop. Why do we use comparison with the input line?
I have to do something similar and I would like to know exactly what I am doing. So, if someone knows how it works
I would really thank him/her.
Vicente
0 Kudos
Message 1 of 2
(2,784 Views)

The comparison is not done with the input line, but with an empty string. The input line control is only changed when you leave it or click enter, so the inside loop waits until you finished typing (the string is not empty) and only then it sends your string.

Actually, there are many things wrong with this example. For example, there is a race condition where the input string control is set to an empty string, but the loop could check before the control is actually cleared. It would have been cleaner to check for an empty string (and in newer versions, to just use an event structure, although that example is older) and so on.

For a better example, have a look at the multiple connections example. Also, you should have a look here.

It's important to handle connections over time. For example, keep a running counter of timeout errors (56). When you receive data, reset the counter. If the counter exceeded a limit, close the connection and reopen it.


___________________
Try to take over the world!
0 Kudos
Message 2 of 2
(2,767 Views)