LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reconnect TCP connection

Hi,
Is there a way to have a passive TCP communicator open and constanly running and use an active one that connects, disconects, and then automatically reconnects periodically? I'm using the active TCP vi as a sub vi to send commands to another computer but I need to send all the commands seperately. Also, the main vi does other stuff in between those commands, so I can't just leave the active connection open. There is an example vi called "reconnect TCP connection", but I can't open it because it is for labview version 7.1 and I'm using labview 8.5. I don't know if it would even do what I want, but if anyone knows how to get around the old version problem (or locations on examples for labview 8.5), please let me know. Any help/ideas would be amazing, Thanks!
0 Kudos
Message 1 of 6
(4,499 Views)
Hi ekarl,
there is no problem to open LV7.1 vi´s with LV8.5. You can run a listener on your server and build for every command a new connection to your server.

Hope it helps.
Mike
0 Kudos
Message 2 of 6
(4,497 Views)
It depends on how far apart the packets are. If they are going to be sent pretty regularly, you can just put a TCP Read in your main loop with a timeout of maybe 100 ms. If nothing comes in that 100 ms, clear the error (56) and process your other code. If the packets are not sent very regularly and you don't want to wait every iteration of your main loop listening for 100 ms, you can use a Producer/Consumer pattern with the producer has a wait on listener, and when it receives information, puts it in a queue for the consumer loop (which will run the bulk of your program). I modified the template of producer consumer to give you an idea how to work it. Problem with this method is it's difficult to communicate back to the producer loop (for example, of you quit the program from the consumer, the producer will continue to run and the VI won't stop.) This may be a rare example of where it's ok to use local variables.



0 Kudos
Message 3 of 6
(4,489 Views)
MikeS81
that makes a lot of sense, thanks so much for your help! 🙂
0 Kudos
Message 4 of 6
(4,487 Views)
StevenD,
The part you said about how to deal with packets that aren't sent very regularly sounds like it would be a huge help to me. I was wondering if you could send a screenshot or something of the vi you attatched because I keep getting an error when I try to open it. Thanks!
0 Kudos
Message 5 of 6
(4,485 Views)



Message Edited by StevenD on 06-09-2008 02:03 PM
0 Kudos
Message 6 of 6
(4,481 Views)