LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCPIP select

I have a situation where I need to monitor several dozen TCPIP connections for activity.  I'm wondering if it is possible to, in effect, use the socket select function within Labview (I don't see this function directly available) to avoid polling all these connections.  Alternatively, if I code this with multiple threads do they automatically coordinate using the socket selection function or does each run independently?  I'm concerned that many threads with a small polling interval will consume too much system resources for other parallel tasks to run effectively.

 

Thanks

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

Native LabVIEW TCP primitives don't give very good feedback regarding the state of a connection. You can call into the Winsock library. What exactly are you trying to do? When you say activity do you mean data available that will be read? Or are you simply trying to determine if there is activity on the connection. The first is not really a problem and can be written to avoid heavy CPU usage. I don't think the second is possible.

 

If you are simply reading data as it comes in you don't have to have tight polling loops. You can use the timeout value on the TCP Read to control the processing. You can configure the read to read some number of characters (how much is determined by how your data is formatted.) with a reasonable timeout. For example you could use 1000 ms. While the read is waiting for the data or the timeout to occur that thread will basically be idle and therefore consuming no CPU time. An alternative if you need data faster is to read smaller amounts of data and post that to a queue for processing.

 

I have written stuff with dozens of active connections running in parallel and have not run into performance issues. The trick is to write your code correctly to avoid such an effect.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 3
(2,252 Views)

In addition to what Mark said, LabVIEW is using select() internally when waiting for data to read. So the timeout solution Mark mentioned basically would do the trick you want to do, unless your requirements are much more involved than I can understand from your post.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 3
(2,237 Views)