How can I programmatically get the Internet IP address?
1) If the computer is directly connected to the Internet using a USB modem.
2) If the computer is connected to the internet via another computer or a modem/router.
I there a way to do both?
P.S. This link gives exactly the Internet IP, but how can I use it in my program?
You need to talk to an external server. Issuing HTTP requests to sites like http://checkip.dyndns.org or http://www.whatismyip.com will do the trick.
To do the HTTP request, you can for example use libcurl.
If you want to access a web page via c++, go for CurlPP. Use it to download the whatismyip-page you already found and you're done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With