From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I cancel TCP Open Connection prior to timeout?

I want to programatically cancel on ongoing TCP Open Connection prior to its timeout expiring. How do I do it? I'm using LV 2012.

 

I took a look at this thread: How to kill TCP-IP Listen or Open Connection while they are waiting to connect? but it didn't help.

 

I'm thinking I could put the TCP Open Connection in a VI, then invoke the VI by opening a VI reference to it and starting an asynchronous call that gives me a reference to the running VI. I could then use an Invoke Node on that reference to call Abort VI when I want to terminate it.

 

I tried this in the LabVIEW environment (i.e. I didn't compile) with a dummy infinite loop VI that blinked a boolean indicator. It worked (the subVI stopped and the invoking VI continued), and did not cause an error 1000 despite the help's admonitions to only use Abort VI on a top-level VI.

 

So far so good, but am I asking for trouble? And is there a more elegant way to do this in general, i.e. abort a SubVI that for reasons beyond my control doesn't have a canned abort function?

 

Thank you.

0 Kudos
Message 1 of 3
(2,715 Views)

I would put the TCP Open Connection into a FOR loop.  Set the loop to run up to 10 times and set the timeout to 1/10 of what you would normally want.  You can right-click on the FOR loop to show the conditional terminal.  With that, you can stop your loop prematurely if you either got a connection or you want to abort.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3
(2,675 Views)

If the case of TCP Open Connection, repeatedly calling it with a short timeout is not equivalent to calling it once with a long timeout. If it really takes ten seconds to connect and you call it every second with a one-second timeout, it will never connect; it needs to be called with at least a 10-second timeout, which I want the user to be able to abort.

 

Incidentally, I compiled my infinite loop test and it worked as an application. Next step is to try it with TCP Open Connection.

0 Kudos
Message 3 of 3
(2,671 Views)