Get global IP

How can I get (in C ++) the global IP address of my computer (Windows XP)?

+3
source share
4 answers

You can not.

You can define IP addresses on different interfaces, and there can be several. These can be the IP addresses of the local network (10.0.0.0/8, 192.168.0.0/16, etc.), or they can be routed over the Internet.

It seems you are asking: "If I have 192.168.0.3, how can I get my IP address on the Internet?" There is no function call for this: such an IP may exist, it may not exist, maybe even more than a few.

, : - , , , IP-. -, API- .

, uPnP, , .

+4

, gethostbyname winsock2, IP-.

: http://tangentsoft.net/wskfaq/examples/ipaddr.html

Linux:

IP-

+1

You will need to make a request to the website, for example http://whatismyipaddress.com/, and extract the line that displays your IP.

+1
source

Use this simple IP url: get ip

+1
source

Source: https://habr.com/ru/post/1754048/


All Articles