LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

One client trying to access two TCP servers

I have a LabView application on a PC that tries to access two Compact FieldPoint units to retrieve data.  The same LabView code is running on each FieldPoint, and each is sending data as a TCP server.  When my client application only tries to access one cFP unit, everything works fine.  When I add the code to try to access both cFP units, it only picks one, and does not communicate with the other one.  I'm not sure why this is, since my client is trying to communicate with different IP addresses.  I have tried changing the TCP port for the second server and client access so that it did not match the first server's port, but that did not help.
 
I have attached some code to give an example of what I am using both server side and client side.  Note that this vi will not actually run my scenario, because it has the code for both the servers and the client in one vi.  I created it for demonstrational purposes only.
0 Kudos
Message 1 of 4
(2,478 Views)

Are you actually using two seperate loops to talk to the two servers as shown in the example?

If you are then I see no reason one loop should affect the other. If you're not, then a good way of handling different connections in the same loop is by creating an array of refnums and auto-indexing through it or spawning a dynamic VI for each connection (see the example finder).

If this doesn't help you I suggest you explain more clealy what you mean by "picks one". If you want to see a tutorial on using such a communication protocol search the site for "TCP messaging".


___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(2,473 Views)

Do you have a tutorial in mind?  Everyone I read talks about one server handling two clients, but not the other way around.

When I say "picks one"  I mean that one of the client while loops (which run independently) will communicate normally with its server, and the other does not make the TCP connection at all.  It seems whichever while loop the client's processor executes first wins, and the other is shut out.  If I delete one of the client while loops, the other will work everytime.  Its really frustrating.

0 Kudos
Message 3 of 4
(2,472 Views)

Although I missed the fact that the FPs are the servers, I don't believe this matters - the client\server part is only about how you establish communication. One of the examples in the example finder should show how to decouple the connection part from the communication part.

In any case, I still don't see why this doesn't work. Unless you're doing something like assigning the same local port to both loops or making them somehow dependant on each other this should work properly. We might need to see an image of your actual code.

BTW, if you're only transferring a single piece of information, you could think about doing this another way, like publishing a data item which you can read with the FP VIs (although I don't remember if you can do strings and complex data types) or the RT comm wizard.


___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(2,462 Views)