LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 way TCP connection using IP addresses

Hi All,
I need to pass data in both directions between 2 pc's connected to the internet. I am aware of the various TCP/IP and data socket examples, I am using Labview 7.0. I dont know much about the ptotocol involved but figure I only need a few pieces of info.
If the server machine wants to connect to a client machine on the same network I understand no changes are required to the example vis (ie port 2055 used in Simple Data Server). But what would happen if the server PC wanted to connect to a client in a different country? Is that when IP addresses are needed?

I imagine my final vi front panel will have a "This machines IP Addr" and "Client's IP Addr" text box, operators of the machines then tell the other person their mac
hine IP address which is entered manually to setup a 2 way link.

Is it possible to get Labview to find the full IP address of the machine ready for the other user to type in. Thanks in advance
Regards Chris
0 Kudos
Message 1 of 5
(3,715 Views)
On the client side the users will need to fill in the IP address or domain of the server. If that IP is on the Internet or somewhere else that will work as long as the client PC has physical access and permission to open a tcp connection (no firewalls that block the port you are using etc.)

Make a connect dialog that pops up if the user chooses to connect and have the user input the IP there and click OK. You can add functionality like bookmarks and "home page" to make things easier. If a home page / server is defined the client can connect to that upon startup. You may want also to add functionality that will reconnect in the background if the connection is lost.

The client's IP is of less interest. If you need it though just use the string to IP function
and the IP to string function from the tcp/ip palette. Do not wire anything to the former funtion but wire it's output to the latter. The latter will then output the IP of the local PC.
0 Kudos
Message 2 of 5
(3,714 Views)
Mads,
Thanks for that, I am struggling, My current PC configuration is one 98SE PC connected to the internet using broadband and a XP laptop connected to the net using a 56.6k modem. I tried using Simple Data Server, Simple Data Client vi's. I found what I think is the IP address of the PC which I set to server and tried substituting the text "localhost" on the client vi with the PC IP address.

I can get both vi working on one machine at the same time but I cannot the get the client to receive data via internet (TCP/IP ?) on the laptop. Is more IP address needed? ie. default gateway & subnet mask or is the IP address enough?
Help. Regards Chris
0 Kudos
Message 3 of 5
(3,714 Views)
Hi,
the first thing to check is that the IP's are valid by "ping"ing them.
Go to the DOS window, and type ping xxx.xxx.xxx.xxx
and see if you get replies or timeouts.
If you can ping one machine from another, then communication is possible.
You might find that the machines are on different subnets, and this might cause you problems, or that the PC's are behind firewalls, which is blocking the port, as Mads said.

Hope that helps

Sacha Emery
National Instruments (UK)
// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 4 of 5
(3,714 Views)
Hi Sacha,
Your comments put me on the right track, thankyou.
I have nearly zero experience of networks, although slightly more now.

I tried pinging with no message from the other machine and realised I needed a network operating between the 2 machines before I could run a Labview client and server successfully.I purchased a RJ45 crossover patch cable (PC to PC) and I used my Win XP machine which had a fairly painless procedure to setup the network. Finally I retried simple server on one machine and client on the other and success.

As a Network novice setting up a TCP link between 2 or more machines, I didnt realise I had get a network running then buy a (patch cable or) hub and cables, then check available machines in the current networ
k by pinging.

Ideally I would like to move on further and figure how to talk to machines not on the current network layer but I have a feeling that will involve a lot more resolve.

Many Thanks, Regards Chris
0 Kudos
Message 5 of 5
(3,714 Views)