|
Re: retrieving local ip address: msg#00025lib.boost.asio.user
I am running on WinXP pro sp2 and compile with VC8.0. Some corrections to my previous post. I don't get a "class not found" exception from endpoint::address(), however it returns "0.0.0.0" (I was trying to resolve a query with its retval which caused the exception). I give you below a part of the code that I have the problem. The cout prints "0.0.0.0", is this what it should do before no communication has been done through the socket yet? VirtualPeer(boost::asio::io_service& io_service, unsigned short port) : socket(io_service, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), port)) { boost::asio::ip::udp::endpoint& endpoint = socket.local_endpoint(); std::cout << endpoint.address().to_string() << std::endl; } Yes I already do the work-around with resolver object but I was wondering if there is a better way to do that. Thank you, Themis Christopher Kohlhoff wrote: > I should take a look at that. What platform are you running on? > > Anyway, you can use the name returned by host_name() to do a lookup > using a resolver. E.g.: > > tcp::resolver resolver(io_service); > tcp::resolver::query query(host_name(), ""); > tcp::resolver::iterator iter = resolver.resolve(query); > ... > > Note: this is not the same as enumerating the network interfaces on > the host. Asio doesn't provide any classes for that. > > Cheers, > Chris > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: retrieving local ip address: 00025, Christopher Kohlhoff |
|---|---|
| Next by Date: | memory leak in udp roundtrip example?: 00025, Charlls Quarra |
| Previous by Thread: | Re: retrieving local ip addressi: 00025, Christopher Kohlhoff |
| Next by Thread: | Re: retrieving local ip address: 00025, Christopher Kohlhoff |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |