LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I implement two TCP/IP servers (on two separate machines) and one TCP/IP client (on third machine)

Solved!
Go to solution

I have an application where I need to send data via TCP/IP from two separate machines to a third machine. The machines are on a local area network connected through a network switch. The data are generated independently through data acquisition by the two independent machines before are sent to the client on third machine. Each machine has one network card. Thanks.

0 Kudos
Message 1 of 12
(3,694 Views)
Solution
Accepted by topic author Larrage

Have each server listen on a separate port.  On the client have two loops, each loop attempts to open a connection using the IP address of one of the servers on its respective port.  I have this working currently, including the ability to re-connect automatically if a connection is lost.  I could put together a stripped down example for you if you need it.

 

It is based upon the STM framework, you will need to find that on the NI website and download it.  It includes some great examples.

Message 2 of 12
(3,686 Views)

Thanks TLE!

I'd appreciate it if you could point me to the link on NI website with the examples, and If this was not too much troubles for you, a strip down example would also be appreciated. Meanwhile I'll try to make it work using your advice. Thanks again!

0 Kudos
Message 3 of 12
(3,670 Views)

Hi Larrage,

you'll also find very got examples in the example finder. Search for TCP/IP and you'll get a list of VI's with Client and Server solutions.

 

Mike

Message 4 of 12
(3,665 Views)

If you have three separate machines, you don't need to use separate ports.  They will have three IP addresses.

 

Remember this rule: TCP connections are EXACTLY like telephone connections.

 

Have your client open two connections: same port on two different IP addresses.

Each client listens for connections.

 

After connections are established, you get to decide the protocol:  maybe the client should explicitly ask for data, maybe the servers just dump it without being asked. It's up to you.

 

Read this:

TCP tips and tricks

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 5 of 12
(3,655 Views)

Hi Larrage,

 

Here is a link to the STM library. There is a download link at the bottom

 

LabVIEW Simple Messaging Reference Library (STM)

 

 

 

 

Joe Daily
National Instruments
Applications Engineer

may the G be with you ....
Message 6 of 12
(3,615 Views)

Do you still need me to par down an example?  And yes, you can use the same port numbers.  Thanks to who pointed that out.

Message 7 of 12
(3,611 Views)

Hi TLE,

 

I just checked out the example pointed by the link. I am OK with it...I will work it through. I've implemented and tested the system using your suggestion yesterday. This forum works.

 

Thanks for the help!

 

0 Kudos
Message 8 of 12
(3,593 Views)

Thanks Joe!

0 Kudos
Message 9 of 12
(3,591 Views)

Hi TLE,

 

Please elaborate more on the ability to automatically reconnect.  I have a situation where multiple machines need to communicate status to one machine but they are not always on line.

 

Thanks,


DJ

0 Kudos
Message 10 of 12
(3,102 Views)