
Hi, I'm using the boost library to create and manage a UDP socket. I was wondering if there is a way to know the public address of my machine using the boost classes. With this code udp::endpoint thisendpoint(udp::v4(), UDPPORT); boost::asio::ip::address myaddress = thisendpoint.address(); std::cout<< "__My IP address: " << myaddress.to_string() << std::endl; I can only print the any_address (0.0.0.0)... thanks, p_viotti

On Aug 14, 2009, at 2:49 PM, Paolo Viotti wrote:
Hi,
I'm using the boost library to create and manage a UDP socket. I was wondering if there is a way to know the public address of my machine using the boost classes. With this code
udp::endpoint thisendpoint(udp::v4(), UDPPORT); boost::asio::ip::address myaddress = thisendpoint.address(); std::cout<< "__My IP address: " << myaddress.to_string() << std::endl;
I can only print the any_address (0.0.0.0)... thanks,
p_viotti _______________________________________________
You can always adress your own machine via the special ip adress 127.0.0.1 (or the special domain localhost) ------ What is a woman that you forsake her, and the hearth fire and the home acre, to go with the old grey Widow Maker. --Kipling, harp song of the Dane women Tommy Nordgren tommy.nordgren@comhem.se

"Tommy" == Tommy Nordgren
writes:
Tommy> On Aug 14, 2009, at 2:49 PM, Paolo Viotti wrote: >> Hi, >> >> I'm using the boost library to create and manage a UDP socket. I >> was wondering if there is a way to know the public address of my >> machine using the boost classes. With this code >> >> udp::endpoint thisendpoint(udp::v4(), UDPPORT); >> boost::asio::ip::address myaddress = thisendpoint.address(); >> std::cout<< "__My IP address: " << myaddress.to_string() << >> std::endl; >> >> I can only print the any_address (0.0.0.0)... thanks, >> >> p_viotti _______________________________________________ Tommy> You can always adress your own machine via the special Tommy> ip adress 127.0.0.1 (or the special domain localhost) But that hardly qualifies as the 'public address' the OP was after. That said, I've no idea about the answer... --

Hello Paolo,
I'm using the boost library to create and manage a UDP socket. I was wondering if there is a way to know the public address of my machine using the boost classes.
Using a resolver to retrieve the address from the host name seems to do the trick:
#include <iostream>
#include

Paolo Viotti wrote:
Hi,
I'm using the boost library to create and manage a UDP socket. I was wondering if there is a way to know the public address of my machine using the boost classes.
Connect to http://whatismyip.com/automation/n09230945.asp and read what it returns. KTC -- Only two things are infinite, the Universe and Stupidity. And I'm not quite sure about the former. - Albert Einstein
participants (5)
-
Björn Karlsson
-
KTC
-
Maurizio Vitale
-
Paolo Viotti
-
Tommy Nordgren