01-27-2006 03:49 AM
01-27-2006
05:31 AM
- last edited on
12-03-2025
01:54 PM
by
Content Cleaner
It is possible, it's just not a smart thing to do, because a refnum will only be valid from the time you open it to the time you close it (or stop the top level VI).
If the Write TCP VI runs before the Open does, the refnum does not have any value and is meaningless. That is known as a race condition and is very easy to get to if you're using globals.
If you call the Open VI to get the refnum and then seperately call the Write VI, the refnum will again be meaningless even though you have a number because when the VI calling the Open VI stopped the connection was dropped.
There are 2 ways to do this:
You should think about whether you really need the refnum in a global. I find it best to place all my TCP communication in a single place and to bring the necessary data to that location. Then, you get less surprises.
To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).