Here is my problem: I'm using boost::asio::ip::tcp::iostream to connect to server:
boost::asio::ip::tcp::iostream s(IP, "1237");
And now I want to retrieve my own, local IP address. I have found somewhere in the depths of google how to do it with a socket, but what about a stream? I expect that since tcp::iostream is built on the top of a socket it should be something like: s.local_endpoint().address() but after a long search with google and duckduckgo I have found no clue how to do it. I have tried several most obvious permutations, but still no luck. So, is there any simple way to do it, or do I have to use socket? It only has to work on Linux, if it is important.
Assuming Linux, Use getifaddrs(3)
to get a list of interfaces for the local system.
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