From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can use the function "GetTCPPeerAddr()" to get the IP address of a machine which is in an outer network

Hello,

 

If a machine will connect to my machine through several gateways, can I use the  "GetTCPPeerAddr()" function to get its IP address?

 

 

David

0 Kudos
Message 1 of 5
(2,604 Views)

Yes.

0 Kudos
Message 2 of 5
(2,596 Views)

Note that you can only get the IP address of the node (router) that is connected to the internet. The intranet IP address assigned to the machine by the router will not be available.

0 Kudos
Message 3 of 5
(2,593 Views)

Well, your means that I can just get the router's IP address, but how  to get the outer machine's IP address?

0 Kudos
Message 4 of 5
(2,590 Views)

You cannot get the private IP address assigned by the router to the machine from other machines that are not on your private network. The private address is not unique on the internet and it will not be visible on the internet. If you want the machine's IP address to be available on the internet, then you should connect the machine directly to the internet (your ISP - Internet Service Provider) without going through a router. This way, your machine should get an IP address from your ISP that is unique and visible on the internet.

 

Note, that when your machine is connected to a router, even if the other machine gets the private address of your machine, this address would be useless as it does not uniquely identify your machine. If all you want is a way to identify the machine, just generate a GUID or some other unique identifier and send this to the other machine as a TCP message.

0 Kudos
Message 5 of 5
(2,574 Views)