Results 1 to 8 of 8

Thread: QHostInfo - Unknown Error

  1. #1
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt3
    Platforms
    MacOS X

    Default QHostInfo - Unknown Error

    Hi folks,

    I have written a very simple Application that uses QHostInfo.

    If I use QHostInfo::lookupHost(...) and enter an IP-address it seems to work fine.
    But if I enter a name, the adresses-list is always empty and the errorString says "Unknown error" - every time (except when I enter an invalid address).

    any Ideas?

    Qt Code:
    1. void network::slotRequest()
    2. {
    3. hostName = ui.lineEdit->text();
    4. QHostInfo::lookupHost(hostName, this, SLOT(slotShowResults(QHostInfo)));
    5. }
    6.  
    7.  
    8. void network::slotShowResults(QHostInfo info)
    9. {
    10. if(info.addresses().isEmpty())
    11. {
    12. ui.labelOutput->setText(info.errorString());
    13. }
    14. else
    15. {
    16. ui.labelOutput->setText(info.addresses().first().toString());
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHostInfo - Unknown Error

    Can your machine resolve hostnames properly? What happens if you try to resolve a hostname manually from within a terminal?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: QHostInfo - Unknown Error

    Pinging a website via the windows console works properly...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHostInfo - Unknown Error

    Try writing a simple application that calls gethostbyname() and see if it works.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: QHostInfo - Unknown Error

    ok, so I took the gethostbyname() example from the msdn page and compiled it.
    It is actually able to give me IPs for domain names...

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHostInfo - Unknown Error

    On Windows QHostInfo uses either gethostbyname() or (preferrably) getaddrinfo() and the situation you have ("Unknown error" string) can happen only if getaddrinfo() returns an error different than WSAHOST_NOT_FOUND or WSANO_DATA or when gethostbyname() returns an error different than host not found (11001). Check if getaddrinfo() works for you as you did with gethostbyname().

    What happens if you pass "localhost" as the host name?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: QHostInfo - Unknown Error

    so this is interesting: My project folder is in a network folder (The gethostbyname() example works in the networkfolder).
    When I start my program on a local drive it works...
    What could be the explanation for that?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHostInfo - Unknown Error

    No idea, ask uncle Bill
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QNetworkAccessManager unknown error
    By lipk in forum Newbie
    Replies: 2
    Last Post: 20th March 2011, 13:38
  2. python qt4 unknown fatal error
    By izghitu in forum Newbie
    Replies: 0
    Last Post: 25th January 2011, 19:54
  3. QSslsocket and Unknown error
    By szarek in forum Qt Programming
    Replies: 21
    Last Post: 14th October 2010, 14:20
  4. unknown error reading svg file
    By RickF in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2010, 02:12
  5. QimageReader Unknown Error
    By bhaskar in forum Newbie
    Replies: 1
    Last Post: 2nd June 2010, 08:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.