c++ - QHostInfo issue -
i want method qstringlist of ips associated url, have tow methods , work want of on single method this: qstringlist dnsresolver(qstring host);
void object::test() { qhostinfo::lookuphost("www.google.com",this, slot(lookedup(qhostinfo))); } void object::lookedup(const qhostinfo &host) { if (host.error() != qhostinfo::noerror) { qdebug() << "lookup failed:" << host.errorstring(); } foreach (const qhostaddress &address, host.addresses()) { qdebug() << "lookup success:" << address.tostring(); } }
you can utilize qhostinfo::fromname ( const qstring & name ) blocks during lookup :
qstringlist dnsresolver(qstring host) { qhostinfo hostinfo; qhostinfo returnedhost = hostinfo.fromname(host); if (returnedhost.error() != qhostinfo::noerror) { qdebug() << "lookup failed:" << returnedhost.errorstring(); } qstringlist list; foreach (const qhostaddress &address, returnedhost.addresses()) { list<<address.tostring(); } homecoming list; } c++ qt dns ip
No comments:
Post a Comment