LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview RT: Share TCP connection refnum between parallel loops

Solved!
Go to solution

Hi,

 

I am programming a RT application that sends data via TCP/IP from the RT to a computer. Now, it might happen that the computer crashes and the TCP connection is lost. In my RT program, I would like to have sort of a "TCP connection monitor" that listens constantly for a TCP connection. Once a new TCP connection is established, a second, parallel loop should  use this "new" refnum for sending data. (There will always be just one client.)

 

Now I wonder about the best practice to implement this. I thought of using the same approach as in the example "TCP named service", i.e. creating a TCP listener and constantly waiting for an incoming connection. However, I cannot store that connection refnum id in a local variable that could be used from within another loop...

 

Why is that? What would be a nice way of distributing the connection refnum from one loop to the next? I would prefer to avoid STM since the amount of data might become large and perfomance might decrease...

 

Thanks

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

Can you explain more why you can't pass a refnum through a local variable? There is nothing in LabVIEW that makes this specifically impossible but there might be situations that can make this look more difficult than you expect.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 6
(2,579 Views)

What I tried: I right click on the output terminal "listener ID out" of "TCP Wait on Listener". The submenu "Create" did not offer "Local Variable", as it does for e.g. front panel objects...

0 Kudos
Message 3 of 6
(2,559 Views)
Solution
Accepted by topic author TomD3

All local variables are associated with a front panel control or indicator. You cannot simply create a  local variable from the output of a subVI.



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 4 of 6
(2,553 Views)

oh, I wasn't aware. Thanks!

Just on a side note: would you implement the whole thing differently, e.g. without local variables?

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

@TomD3 wrote:

Just on a side note: would you implement the whole thing differently, e.g. without local variables?


2 options:

1. Make an Action Engine (AE) that handles the communication.  The entire Send-Read Response (or just Send) should be handled inside of the AE.

 

2. Make a Queued Message Handler or Actor that runs in parallel with your loops.  You use a queue to command that loop to send data and possibly read a response.  That QMH should be in full control of the connection.


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 6 of 6
(2,532 Views)