[Interest] Qt not resolving URLs
Tom.Isaacson at navico.com
Fri Aug 9 08:17:31 CEST 2013
> On Tue, Aug 6, 2013 at 11:30 AM, Thiago Macieira <thiago.macieira at intel.com> wrote:
> On terça-feira, 6 de agosto de 2013 11:17:35, Mandeep Sandhu wrote:
> > On Tue, Aug 6, 2013 at 10:21 AM, Tom Isaacson
> <Tom.Isaacson at navico.com>wrote:
> > > I've added a simple browser page to my application using the demo code in
> > > Qt 4.8 as a base:
> > > [QTDIR]\demos\browser
> > >
> > > This works fine in Windows, but when I rebuild the app and try it on my
> > embedded Linux device it fails. While experimenting I found I could load
> > www.google.com by resolving the IP address and using that instead. I
> > added the following code to my app:
> > QHostInfo hostInfo = QHostInfo::fromName(m_url);
> > Just to eliminate the obvious, "m_url" here contains a valid url?
> Or, better yet: does *not* contain a valid URL?
> Oops, yes! It takes a host name or IP addr string as input.
> QHostInfo::fromName takes a host name. Not a URL.
m_url is just a hostname like "www.google.com". I then form the QUrl using fromUserInput() which adds the "http://".
It turns out that "Temporary failure in name resolution" is the error EAI_AGAIN, which getaddrinfo() returns when it doesn't really know what the problem is. It was failing because I was running nslookup as root but the application was running under a user account, and by mistake only root had read permission for /etc/resolv.conf. Once I did "chmod a+r /etc/resolv.conf" everything worked.
To fix this permanently we added a chmod to /usr/libexec/udhcpc.sh so the permission on /etc/resolve.conf is set correctly when it's created.
More information about the Interest