Question

Possible Duplicate:
Get the IP Address of local computer

I want to be able to get the IP address for the machine I'm on in C++ without querying external www.whatsmyip.com, but also want to do it in a platform-independent way. I can find specific examples for both Windows and Linux, but can't think of an easy way to do this in a platform-independent way. I would also consider options of putting an if-statement in depending on the Operating System if this seems like the best/only method.

Was it helpful?

Solution

If you are able to use boost, I highly recommend the boost::asio, which is about as cross-platform as you're going to get.

OTHER TIPS

An alternative to boost::asio may be the POCO Network Library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top