04-14-2014 01:23 PM
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.
04-15-2014 06:50 AM
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.
04-15-2014 07:21 AM
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.