Results 1 to 8 of 8

Thread: Hostlookup using QHostInfo

  1. #1
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Hostlookup using QHostInfo

    Hi,

    I have the following code to perform a host lookup

    Qt Code:
    1. // Perform host lookup
    2. m_DoLookup = true;
    3. m_Lookupid = QHostInfo::lookupHost( Address, this, SLOT( SLOTGetHostIPAddress(QHostInfo)) );
    4.  
    5. // Start short lookup timeout
    6. m_LookupTimer = new QTimer(this);
    7. connect(m_LookupTimer, SIGNAL(timeout()), this, SLOT(SLOTLookupTimeout()));
    8. m_LookupTimer->setSingleShot(true);
    9. m_LookupTimer->start(1000);
    10.  
    11. // Wait for lookup timeout to complete
    12. while( m_DoLookup )
    13. {
    14. qApp->processEvents();
    15. }
    To copy to clipboard, switch view to plain text mode 

    The timeout slot is

    Qt Code:
    1. void SLOTLookupTimeout()
    2. {
    3. // abort host lookup
    4. QHostInfo::abortHostLookup( m_Lookupid );
    5. }
    To copy to clipboard, switch view to plain text mode 

    Now when the QHostInfo::abortHostLookup() is called, I am expecting it to then go into my SLOTGetHostIPAddress(), where I can check for the failure. However, it never goes in there, and always stays in my processEvents() while loop. Any thoughts why?

    I have confirmed the id returned from QHostInfo::lookupHost() is the same as the one passed into QHostInfo::abortHostLookup(). Is it just the case that if i abort a lookup, i don't get anything back saying it has been aborted?

    David

  2. #2
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hostlookup using QHostInfo

    I have also noticed that with the

    QHostInfo::abortHostLookup( m_Lookupid );

    and

    m_Lookupid = QHostInfo::lookupHost( Address, this, SLOT( SLOTGetHostIPAddress(QHostInfo)) );

    calls in my code, my application crashes on exit, whether the lookup completed or not. Not sure why this is yet, will try looking at this.

    David

  3. #3
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hostlookup using QHostInfo

    Still non the wiser about what is causing the crash in my application. Calling the static blocking call,

    QHostInfo fromName ( const QString & name )

    To resolve the host name to ip address does not cause my application to crash, but any call to the static calls

    lookupHost ( const QString & name, QObject * receiver, const char * member )

    or

    abortHostLookup ( int id )

    Causes my application to have an access violtation in qt_call_post_routines(), which is called from the QApplication destructor. Anyone have any ideas why?

    David

  4. #4
    Join Date
    Oct 2009
    Posts
    37
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Hostlookup using QHostInfo

    In which Qt version do you have the crash?

    SLOTGetHostIPAddress won't be called if you abort.
    Disclaimer: Although I work on Qt for Nokia, anything I post here is personal

  5. #5
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hostlookup using QHostInfo

    The crash is in QT 4.5.2.

    I came to the conclusion this might be a QT issue, and am currently in the process of installing QT 4.6.1 on my system.

  6. #6
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hostlookup using QHostInfo

    Also, this is on Windows XP.

  7. #7
    Join Date
    Oct 2009
    Posts
    37
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Hostlookup using QHostInfo

    Great!
    Please report back and tell if it fixes the issue.
    Disclaimer: Although I work on Qt for Nokia, anything I post here is personal

  8. #8
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hostlookup using QHostInfo

    Good news. Upgrading to QT 4.6.1 has resolved the crash on exit of my applciation

Similar Threads

  1. QHostInfo IP Detection under Vista
    By visor_ua in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2008, 16:04
  2. QHostInfo usefullness
    By baray98 in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2007, 14:07

Tags for this Thread

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.