doggrant
21st January 2010, 18:17
Hi,
I have the following code to perform a host lookup
// Perform host lookup
m_DoLookup = true;
m_Lookupid = QHostInfo::lookupHost( Address, this, SLOT( SLOTGetHostIPAddress(QHostInfo)) );
// Start short lookup timeout
m_LookupTimer = new QTimer(this);
connect(m_LookupTimer, SIGNAL(timeout()), this, SLOT(SLOTLookupTimeout()));
m_LookupTimer->setSingleShot(true);
m_LookupTimer->start(1000);
// Wait for lookup timeout to complete
while( m_DoLookup )
{
qApp->processEvents();
}
The timeout slot is
void SLOTLookupTimeout()
{
// abort host lookup
QHostInfo::abortHostLookup( m_Lookupid );
}
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
I have the following code to perform a host lookup
// Perform host lookup
m_DoLookup = true;
m_Lookupid = QHostInfo::lookupHost( Address, this, SLOT( SLOTGetHostIPAddress(QHostInfo)) );
// Start short lookup timeout
m_LookupTimer = new QTimer(this);
connect(m_LookupTimer, SIGNAL(timeout()), this, SLOT(SLOTLookupTimeout()));
m_LookupTimer->setSingleShot(true);
m_LookupTimer->start(1000);
// Wait for lookup timeout to complete
while( m_DoLookup )
{
qApp->processEvents();
}
The timeout slot is
void SLOTLookupTimeout()
{
// abort host lookup
QHostInfo::abortHostLookup( m_Lookupid );
}
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