LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Opening and closing Multiple TCP connections issues

Hi all I am having an issue with the TCP VI’s and wondering if anyone has experienced this issue.

 

My application is required to scan 50-100 IP addresses (statically assigned) and discover if an Ethernet device is connect at that IP address. Currently I am able to achieve this by opening a TCP connection and testing the error cluster to determine if a timeout has occurred (no timeout error  means Ethernet device available at the IP address). I then ensure that the TCP connections are closed.

 

The issue I am have is that I require a 1 second delay between the  TCP open and the TCP close which significantly slows down the process. Without the 1 second delay the vi successfully connects to the device once then fails to make any TCP connect regardless of the time delay until the PC is reset.  

 

If anyone has any advice I would be very grateful

 

David Barr

 

P.S. I have attached a simplified section of code showing this issue

0 Kudos
Message 1 of 5
(3,843 Views)

If I understand you correctly you want the time delay to be 1 second if there's a successful connection, and essentially 0 if there's no successful connection. Is this correct? If that's the case you can simply use the Select function to pick you delay based on an error condition.

 

Also, there's no need to do those mathematics gymnastics with the array indexing. Just auto-index your array. Or, use Format Into String to create your IP address. See attached mod.

0 Kudos
Message 2 of 5
(3,809 Views)

@smercurio_fc wrote:

If I understand you correctly you want the time delay to be 1 second if there's a successful connection....


While I don't have a specific answer for this problem. I want to clarify for him. I believe the issue is, what if all connections ARE there? That means you keep returning a wait of 1 second 50-100 times so It takes 50-100 seconds just to initialize. I think the user is looking for a way to check for valid connections, but do so in such a way that eliminates the need for a wait which is greatly slowing things down.

0 Kudos
Message 3 of 5
(3,801 Views)

What if you configure the For Loop for parallelism?  You might be able to chop the overall execution time down to 1/2, 1/4, maybe less.

 

What if you use a different method such as pinging the IP address?  Could that execute faster?

 

What if you try to open the 100 connections in the loop, but don't close them in the loop.  Just build an array of the connection ID's.  Then after the loop finishes, wait a second, then run another For loop auto-indexing on the array of connection ID's and close the connections.

0 Kudos
Message 4 of 5
(3,791 Views)

Thank you all for the advice.

 

I tried implementing the two loops, one to open the TCP connection and a second to close the connections. This did prove to run more efficiently however I have chosen to to detect the Ethernet devices using the ping command as my tests far have found it is more reliable.

Many Thanks

 

0 Kudos
Message 5 of 5
(3,767 Views)