Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::asio::ip::tcp::resolver::query does not work in Ubuntu!!!
From: mozdemir (mozdemir76_at_[hidden])
Date: 2012-05-12 13:27:16


HI Andreas,

you are right. this is not crash. It is an exception.

I did the following small code to explain the issue better

============================================

#include <iostream>
#include <boost/asio/ip/tcp.hpp>
#include <boost/lexical_cast.hpp>
 

using namespace boost::asio;

int main(int argc, char* argv[])
{
        io_service ios;
        try {
            int i;
            for (i=0;i<1000;i++) {
                int m_port = 80;
                std::string m_host = "www.yahoo.com";
                boost::system::error_code ec;
                boost::asio::ip::tcp::resolver resolver( ios );
                boost::asio::ip::tcp::resolver::query query( m_host,
boost::lexical_cast< std::string >( m_port ));

                boost::asio::ip::tcp::resolver::iterator endpointIterator =
resolver.resolve( query );
                for(;endpointIterator != ip::tcp::resolver_iterator();
++endpointIterator) {
                    std::cout << "i: " << i << " ip: " <<
endpointIterator->endpoint().address().to_string() << std::endl;
                }
            }
 
        } catch(std::exception const& ex) {
                std::cerr << "Error: " << ex.what() << '\n';
        }
}
=============================================

the output goes fine but around 300, it throws the exception.

i: 327 ip: 98.139.183.24
i: 328 ip: 98.139.183.24
i: 329 ip: 98.139.183.24

Error: Host not found (authoritative)

============================================

you are suggesting to handle the exception which I will do. But i wonder why
this is not happening in windows but ubuntu?

I wonder if my ubuntu is missing some configuration. I did install Miredo
for Ipv6 but it did not help.
i feel like this is something to do with network settings issue, NAT issue
or something....

Thank you for the suggestion.
mustafa

--
View this message in context: http://boost.2283326.n4.nabble.com/boost-asio-ip-tcp-resolver-query-does-not-work-in-Ubuntu-tp4628195p4629193.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net