LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you Close a Datasocket Connection with Infinite Timeout?

I work on an application that uses shared variable and datasocket network communication, and some of the variables/datasocket items are rather large but not changing often. So we set up clients to read those items with an infinite (-1ms) timeout, so they only read the data when it changes. The problem is how to close a connection if it is waiting on new data indefinitely.

 

If we use the shared variable API, we can accomplish this as follows

abort infinite timeout.png

 

That is really cool!

 

However, if we use Datasocket, there is no way to kill a read process that is waiting indefinitely, as far as I can tell. I tried using the same idea--passing the connection reference to another process and explicitly closing it, but the close connection attempt returns an error that the connection is in use. Smiley Sad

 

We want to use Datasocket for situations where we have tighter security--since it only uses a single port instead of a wide range like PSP. It would be great if we could do so with an infinite timeout to avoid unnecessary reads of large variables.

 

Does anyone have any suggestions?

 

[I also tried running the VI containing the datasocket read function dynamically and keeping a reference to it, then using the Abort VI method on that reference later. Even that didn't work--the datasocket read seems to be a trump card!]

0 Kudos
Message 1 of 6
(2,952 Views)

All way too complicated.

 

Here's what I do. Use a wait of 1000 ms for the DataSocket Read, followed by a case strucutre. If timeout is true do nothing, otherwise process the data.

 

This 1 secnd "peek" allows a global stop to be read and if necessary exit the loop.

 

User's are not genrally perturbed by waiting a second or two after pressing the user interface STOP button.

0 Kudos
Message 2 of 6
(2,948 Views)

Since some of our variables have contents of several MB of data, and we have multiple (30+) client connections, I really want to avoid the bandwidth hit of polling those items at 1Hz.....

0 Kudos
Message 3 of 6
(2,946 Views)

The extra overhead of timing out of a DataSocket Read and executing an empty case structure once a second is negligible. Even less than negligible!

0 Kudos
Message 4 of 6
(2,943 Views)

It is my understanding--and correct me if I'm wrong--that if a datasocket read times out, it will still pull the latest data on that datasocket item from the remote server over the network. So you will still have a network usage hit, even if you aren't doing anything with the data....

 

I am not concerned with CPU or memory usage; it's only a network bandwidth issue, if there are N clients repeatedly downloading a large, unchanging network variable.

0 Kudos
Message 5 of 6
(2,941 Views)

I don't think that any network traffic would result. You could always test it out by timing out every 1 ms and seeing if network traffic shoots up.

 

My understanding is that a local copy of the latest received data is kept. And that this is not re-obtained from the network.

 

As stated above, easy to test.

0 Kudos
Message 6 of 6
(2,938 Views)