LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Wait On Listener multiple remote addresses from 1 machine

I'm trying to reciever messages from multiple machines and keep track of them by the IP the message came from.  I was using TCP Listen.vi which says it puts the remote address out in dot notation, it doesn't.  Kept sending the name of the machine as near as I can tell.  I saw the create and wait on listener VI's had a boolean to tell it to "resolve remote address indicates whether to call the IP To String function on the remote address. The default is TRUE. Refer to IP To String for more information."  So I switched to that.  Now I'm getting an IP sometimes 192.168.44.89, sometimes a name LabVIEW_Dev_1 and other times a slightly different name labVIEW_dev_1  So I end up with 3 instances tracking on my listener when on 1 machine is sending?  For sure only 1 is sending so far and only 1 adapter is on that network.

0 Kudos
Message 1 of 6
(3,500 Views)

The only time I need to manage connections from different computers I used the TCP Listen to check for a connection, then I sent the connection ID to another loop which was responsible to work the new connection.

 

If you program will always threat the message received from the connection in the same way, you can have a for loop with an array of Connection ID working in a parallel loop.

Guilherme Correa
0 Kudos
Message 2 of 6
(3,431 Views)

Well, I changed to using the Create listener/Wait on Listener, it has a boolean that worked to get the IP.  In general who should close a TCP connection and when?  If I'm going to continue sending data should I keep it open, even if it mite be 2-3 minutes until I have something to send?  Should the Client close it when it's done?  Would the server ever close a connection?   

0 Kudos
Message 3 of 6
(3,399 Views)

A TCP connection can remain open indefinitely with no data passing back and forth. There's no problem keeping a connection open for infrequent data, but it's also a good idea (and not difficult) to reconnect automatically if the connection dies.

 

In my code I often have the server close a connection if it's been more than an hour since it last received any communication from a particular client; otherwise, the client is responsible for closing the connection when it's done communicating. That hour is an arbitrary length of time to prevent old connections from accumulating if for some reason the client doesn't properly close the connection before exiting.

0 Kudos
Message 4 of 6
(3,389 Views)

Thanks for the information.  I was tracking what test station was sending a message by using the IP from the wait on listener.  I only get that when a connection is made, not on subsequent messages.  Anyway to extract any information about the sender from the connection ID?

0 Kudos
Message 5 of 6
(3,377 Views)

I'm not sure what your overall goal is here. Usually what I've done, in a situation with a single server and multiple clients, is a dedicated loop that waits for new connections (using Wait on Listener). When a new connection is established, the new connection reference is put in a queue, where it is retrieved by a second loop. That loop maintains an array of all active connections along with the time that data was last received on each connection, and continuously loops through all open connections looking for new data. This is one way to handle multiple connections; another one is to launch a new copy of a re-entrant VI for each new connection. I posted an image of my usual approach here:

FPGA Butterworth Filter.png

In your case, if you want to track IP addresses, you could add that to the cluster that contains the time stamp, and then when new data arrives on a particular connection you can associate it with the corresponding IP address.

0 Kudos
Message 6 of 6
(3,371 Views)