LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Refnum array

Hello all,

I have a VI that runs as a TCP server, establishing connections and
storing them in an array. However, when I run it a second time (while
keeping the VI in memory), the previous connection IDs are still in the
array. How do I initialize an array of TCP connection refnums?

Thanks,
Stephen
0 Kudos
Message 1 of 5
(3,021 Views)
Although it's hard to say exactly where you are going wrong without seeing your code, here's something to check:

One of the most common ways of running into trouble is to have an array in a shift register that you append values to as a loop runs. If you don't initialize the left node of the shift register with a null array outside the loop, you will append more and more values each time the VI runs.

If that isn't your problem, post your code and I'll be glad to check it out...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(3,021 Views)
Thanks for the reply,

http://home.satx.rr.com/srgray/

At this site is the file, TcpServerNI.vi. In it, I'm trying to build an
array of Tcp Connection IDs and then do something with those elements in
the array. My problem is that I don't know how to initialize that array
on startup to "no elements" or empty. The way I usually do this for
other data types is shown by the Example Array in the VI. (I just right
click on the array and do Create Constant which gives me an empty array
constant.) However, when I try that with the array of Connection IDs,
Create Constant is grayed out.

Any help is appreciated,
Stephen

mikeporter wrote:
> Although it's hard to say exactly where you are going wrong without
> seeing your code, here's something to check:
>
> One o
f the most common ways of running into trouble is to have an
> array in a shift register that you append values to as a loop runs. If
> you don't initialize the left node of the shift register with a null
> array outside the loop, you will append more and more values each time
> the VI runs.
>
> If that isn't your problem, post your code and I'll be glad to check
> it out...
>
> Mike...
0 Kudos
Message 3 of 5
(3,021 Views)
Ok, I see the problem (which by the way is corrected in LV7). The way to generate a null array of references is to use the initialize array function. Tie a reference of the appropriate type to the element input and set the dimension input to zero. The result is a null array of the correct type.

You should also try to lose some of the local variables as are generating unnecessary complexity in your code. This sort of application is exactly why we have shift registers. Also it looks like the top loop is just opening the same connection over and over again--ad infinitum.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 5
(3,021 Views)
Mike,

Thanks, that worked. You're right, the code is definitely not efficient
! The top loop listens constantly for new connections and builds an
array of connection refnums to send data over those connections in the
bottom loop.

-Stephen

mikeporter wrote:
> Ok, I see the problem (which by the way is corrected in LV7). The way
> to generate a null array of references is to use the initialize array
> function. Tie a reference of the appropriate type to the element input
> and set the dimension input to zero. The result is a null array of the
> correct type.
>
> You should also try to lose some of the local variables as are
> generating unnecessary complexity in your code. This sort of
> application is exactly why we have shift registers.
Also it looks like
> the top loop is just opening the same connection over and over
> again--ad infinitum.
>
> Mike...
0 Kudos
Message 5 of 5
(3,021 Views)