2

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.

Community
  • 1
  • 1
cooper
  • 315
  • 1
  • 16

2 Answers2

2

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.

Moo-Juice
  • 38,257
  • 10
  • 78
  • 128
1

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

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
  • I know that Boost compiles on Blue Gene/P, but not sure about POCO. One of the systems I am working with is BGP, so I will need the included libraries to cross-compile as well. – cooper Dec 05 '12 at 20:48