Results 1 to 6 of 6

Thread: How to read the content of DNS record?

  1. #1
    Join Date
    Jan 2013
    Posts
    17
    Thanks
    9

    Default How to read the content of DNS record?

    I have multiples DNS record (MX, CNAME , TXT) and I would like to read the TXT record content.

    Is it possible?
    Is there any example?

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to read the content of DNS record?


  3. #3
    Join Date
    Jan 2013
    Posts
    17
    Thanks
    9

    Default Re: How to read the content of DNS record?

    Could you help me, please?

    The lookup() function never emit finished() or error(), I tried using this code:

    Qt Code:
    1. m_dns = new QDnsLookup(this);
    2. connect(m_dns, SIGNAL(finished()), this, SLOT(onHandle()));
    3.  
    4. m_dns->setType(QDnsLookup::TXT);
    5. m_dns->setName("uol.com.br");
    6. m_dns->lookup();
    7.  
    8.  
    9. void Update::onHandle()
    10. {
    11. if (m_dns->error() != QDnsLookup::NoError)
    12. qDebug() << m_dns->error() << m_dns->errorString();
    13.  
    14. foreach (const QDnsServiceRecord &record, m_dns->serviceRecords()) {
    15. qDebug() << "Name: " << record.name() << "Target: " << record.target();
    16. }
    17.  
    18. emit handled();
    19. }
    To copy to clipboard, switch view to plain text mode 

    Thanks any help,

  4. #4
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: How to read the content of DNS record?

    QDnsLookup appears to use a thread pool to perform its DNS lookup requests. Do you have an event loop running at the time you do the m_dns->lookup()?

    Edit: Also, you said you're looking for TXT records, so your OnHandle slot should be looking at m_dns->textRecords(), not m_dns->serviceRecords(), correct?
    Last edited by jefftee; 7th July 2015 at 06:12.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  5. The following user says thank you to jefftee for this useful post:

    ricardodovalle (7th July 2015)

  6. #5
    Join Date
    Jan 2013
    Posts
    17
    Thanks
    9

    Default Re: How to read the content of DNS record?

    Thank you very much! It is working with m_dns->textRecords()

  7. #6
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: How to read the content of DNS record?

    Glad its working for you, but I thought your issue was that the finished() signal was never fired? What did you change to get that working?
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

Similar Threads

  1. fastest way to read large files (with mixed content)
    By timmu in forum Qt Programming
    Replies: 8
    Last Post: 10th September 2012, 11:09
  2. read ini file content and save into array
    By cooper in forum Newbie
    Replies: 8
    Last Post: 14th March 2011, 22:33
  3. QDomDocument can't read the file content
    By baluk in forum Newbie
    Replies: 21
    Last Post: 24th September 2010, 14:43
  4. Read SMS in-box content & show it in QListWidget?
    By damodharan in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2010, 06:51
  5. read and write content of lineedit widget in Other Form
    By validator in forum Qt Programming
    Replies: 1
    Last Post: 25th April 2008, 16: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.