LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can a store a tcp connection refnum as a local variable?

I want to access several tcp-vis (read and write) in a state-machine by creating after the tcp-listen vi a local variable from the tcp connection refnum. Error 1 always occured after running the vi. How can I pass the refnum to other subVIs?
0 Kudos
Message 1 of 2
(2,482 Views)
mhi,

There should be nothing to prevent you from successfully coding this, although if you search the NI support site for 'tcp "error 1"', you will find that others have encountered the same problem in the past.

Somehow, you must be closing or overwriting the connection refnum before it is used by a TCP Read or TCP Write node. I will note that this is much easier to do by accident when you use local variables, as opposed to just using a shift register. One good technique with state machines is to populate a single shift register with a cluster of your frequently-used program data. You can do this in an Initialize state and then access that cluster from all subsequent states.

You can convince yourself that it's possible to do it your way by opening up the shipping TCP example pair entitled TCP Communicator - Active.vi and TCP Communicator - Passive.vi and changing the block diagrams so that a local variable is used instead of a wire in the while loops. However, I still recommend shifting to an alternative, non-local approach, because you will probably save yourself other headaches down the line.

Regards,
John
Message 2 of 2
(2,473 Views)