Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::asio::ip::tcp::resolver::query does not work in Ubuntu!!!
From: Andreas Wehrmann (a.wehrmann_at_[hidden])
Date: 2012-05-12 03:50:50


> Hi,
>
> I am a newbie with Asio library and i got into crashing problem with the
> following code:
>
>
> boost::system::error_code ec;
> boost::asio::ip::tcp::resolver resolver( m_hive->GetService() );
> 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 );
>
> When i run this in windows, i do not have any isssue but in Ubuntu, it works
> and after some more resolution of query, it crashes. I did install Miredo to
> activate Ipv6 but it did not help.
>
> When the crash happens, i see this:
>
>
> 23:37.47 [dbg] [0x8ec0650] Exception: Host not found (authoritative)
> 23:37.47 [dbg] [0x8ec0650] Exception: Host not found (authoritative)
> terminate called after throwing an instance of
> 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector&lt;boost::system::system_error>
>> '
> what(): Host not found (authoritative)
> Aborted (core dumped)
>
>
> Do you know what else is missing or what is wrong?
>
> Thanks a lot,
> mustafa
>

Provided your output, this is not a crash but just the case of an
unhandled exception.
Take a look at this:

http://www.boost.org/doc/libs/1_49_0/doc/html/boost_asio/reference/ip__basic_resolver/resolve/overload1.html

It says that resolve() throws an exception on error
so you can either catch it or use the overload where you need
to provide an error handle yourself (which is not much different
since you need to handle errors anyway).

Regards,
Andreas


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