How do you get the ip address from a remote machine?
问题 I'm writing c++ code that I need to run on both windows and linux and I'm looking for a function call that will return the ip address of the box the app is running on. Is there such one? 回答1: IF you can use boost, take a look at How to get IP addresss of boost::asio::ip::tcp::socket? 回答2: Call socket(), then getsockname(). 回答3: You can do it but it's generally a bad idea. ioctl SIOCGIFCONF as described in "man netdevice" explains this. The reason it's a bad idea is that you probably won't get