Results 1 to 19 of 19

Thread: Unable to resolve the IP address. ( Qt 3.)

  1. #1
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Unable to resolve the IP address. ( Qt 3.)

    Hi

    What i did ..
    In my application , we are trying to send mails.
    The user should be able to attach file ...

    Problem ...
    i have a function called void Smtp::dnsLookupHelper() . Here it is not able to resolve the DNS SERVER NAME in string . say "ourserver.com"
    Qt Code:
    1. socket->connectToHost( s.first().name ,25 ); // s.first().name = "ourserver.com"
    To copy to clipboard, switch view to plain text mode 

    see the code in this void Smtp::dnsLookupHelper()
    Qt Code:
    1. void Smtp::dnsLookupHelper()
    2. {
    3. QValueList<QDns::MailServer> s = mxLookup->mailServers();
    4. QValueList<QDns::MailServer>::Iterator it = s.begin();
    5. while( it != s.end() )
    6. {
    7. qDebug("%DNS-Server:"+QString("%1").arg( (*it).name ));
    8. ++it;
    9. }
    10.  
    11.  
    12.  
    13.  
    14.  
    15. if ( s.isEmpty() && mxLookup->isWorking() )
    16. {
    17. emit status( tr( "Could not find mail server. Please check address." ) );
    18. QMessageBox::warning( qApp->activeWindow(),
    19. tr( "SynsupMail" ),
    20. tr( "Could not find mail server for address:\n\n %1" ).arg( rcpt ) );
    21. QTimer::singleShot( 0, this, SLOT(deleteMe()) );
    22. return;
    23. }
    24.  
    25. emit status( tr( "Connecting to %1" ).arg( s.first().name ) );
    26. socket->connectToHost( s.first().name ,25 ); // Not able to resolve the DNS name.
    27. //socket->connectToHost( QString("192.168.45.55"), 25 ); //this will work, as i given the IP address directly
    28. t = new QTextStream( socket );
    29.  
    30. }
    To copy to clipboard, switch view to plain text mode 

    if am giving the DNS SERVER NAME like this "192.168.45.55" this will work . Why ..????


    please help

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

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Is the DNS able to return a proper IP for that hostname? Do you get the expected result in the while() loop?

  3. #3
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Quote Originally Posted by wysota View Post
    Is the DNS able to return a proper IP for that hostname?
    How can I get an IP address from QDns::MailServer.name ??

    I tried this below code
    Qt Code:
    1. QValueList<QDns::MailServer> s = mxLookup->mailServers();
    2. QValueList<QDns::MailServer>::Iterator it = s.begin();
    3. while( it != s.end() )
    4. {
    5. qDebug("%DNS-Server:"+QString("%1").arg( (*it).name )); // display "ourserver.com"
    6. ++it;
    7. }
    To copy to clipboard, switch view to plain text mode 
    I think
    Qt Code:
    1. socket->connectToHost( s.first().name ,25 );
    To copy to clipboard, switch view to plain text mode 
    should resolve the QDns::MailServer.name to IP address.

  4. #4
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    What sort of DNS entry is "ourserver.com"? Can you "ping" it from a command line, and does this return the correct IP? If not (and your DNS servers are correctly set up) its probably an MX (Mail Exchange) record, used to provide mail domain services, such as "@ourserver.com". You can prove this using "nslookup" tool, changing the type=MX. If its published on the internet, you can use the "DNSStuff" website for this as well. If its on an intranet, the simplest way would be to request a new DNS A (alias) record from the admins, like "smtp.ourserver.com", and use that - this would pretty much work with most platform variants of "gethostbyname()" - you can always test this by poking the hosts file.

    Just my 5c.

    Pete

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

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Quote Originally Posted by joseph View Post
    How can I get an IP address from QDns::MailServer.name ??
    Something equivalent to:

    dig -t mx ourserver.com

    and then:
    host server.returned.for.ourserver.com

    I think
    Qt Code:
    1. socket->connectToHost( s.first().name ,25 );
    To copy to clipboard, switch view to plain text mode 
    should resolve the QDns::MailServer.name to IP address.
    Only if it is resolvable by your machine. That's why I asked to check it out.

  6. #6
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Quote Originally Posted by pdolbey View Post
    What sort of DNS entry is "ourserver.com"? Can you "ping" it from a command line, and does this return the correct IP?
    Pete
    Ok Pete, sounds very difficult to understand for me, newbiew so please bear with me if I ask stupid question

    Can you "ping" it from a command line, and does this return the correct IP?
    When I ping on the terminal , I get this reply
    >ping gmail.com
    From 192.168.1.7: icmp_seq=1 Destination Host Unreachable
    From 192.168.1.7 icmp_seq=1 Destination Host Unreachable
    for gmail.com.
    You can prove this using "nslookup" tool, changing the type=MX. If its published on the internet, you can use the "DNSStuff" website for this as well. If its on an intranet, the simplest way would be to request a new DNS A (alias) record from the admins, like "smtp.ourserver.com", and use that - this would pretty much work with most platform variants of "gethostbyname()" - you can always test this by poking the hosts file.
    I need some more explanation for this as I'm not getting anything

    wysota-->
    dig -t mx gmail.com
    I get this
    Qt Code:
    1. ; <<>> DiG 9.3.2 <<>> -t mx gmail.com
    2. ;; global options: printcmd
    3. ;; Got answer:
    4. ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27225
    5. ;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 4, ADDITIONAL: 6
    6.  
    7. ;; QUESTION SECTION:
    8. ;gmail.com. IN MX
    9.  
    10. ;; ANSWER SECTION:
    11. gmail.com. 1619 IN MX 5 gmail-smtp-in.l.google.com.
    12. gmail.com. 1619 IN MX 10 alt1.gmail-smtp-in.l.google.com.
    13. gmail.com. 1619 IN MX 10 alt2.gmail-smtp-in.l.google.com.
    14. gmail.com. 1619 IN MX 50 gsmtp163.google.com.
    15. gmail.com. 1619 IN MX 50 gsmtp183.google.com.
    16.  
    17. ;; AUTHORITY SECTION:
    18. gmail.com. 267625 IN NS ns1.google.com.
    19. gmail.com. 267625 IN NS ns2.google.com.
    20. gmail.com. 267625 IN NS ns3.google.com.
    21. gmail.com. 267625 IN NS ns4.google.com.
    22.  
    23. ;; ADDITIONAL SECTION:
    24. gsmtp163.google.com. 5221 IN A 64.233.163.27
    25. gsmtp183.google.com. 5221 IN A 64.233.183.27
    26. ns1.google.com. 23924 IN A 216.239.32.10
    27. ns2.google.com. 23924 IN A 216.239.34.10
    28. ns3.google.com. 23924 IN A 216.239.36.10
    29. ns4.google.com. 23924 IN A 216.239.38.10
    30.  
    31. ;; Query time: 1 msec
    32. ;; SERVER: 192.168.1.7#53(192.168.1.7)
    33. ;; WHEN: Wed Jul 4 09:24:40 2007
    34. ;; MSG SIZE rcvd: 326
    To copy to clipboard, switch view to plain text mode 
    host server.returned.for.ourserver.com
    I get this
    Host server.returned.for.gmail.com not found: 3(NXDOMAIN)
    I even tried using the smpt example given in qtassistant( qt3 ) and I get error as "Connection refused". Please help.

    Thanks

  7. #7
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Ok let me explain what I did again.

    Copied the code from "A simple mail client" available in qtassistant (qt3). Compiled the code and ran it.
    See the attached file below.
    See the information in the status bar. I keep getting that. Also when I debugged to find out what is wrong with the code, I got to know the DNS name is not resolved to host address and I get the error "ErrConnectionRefused".
    Attached Images Attached Images

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

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    I meant to use "host" on one of the results returned by dig, like:

    host gmail-smtp-in.l.google.com

    And then you can even do:

    /usr/sbin/traceroute gmail-smtp-in.l.google.com

    and see if you're able to reach the host.

  9. #9
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Ok,
    I have tried this
    Qt Code:
    1. abc@abc:~>host gmail-smtp-in.l.google.com
    2. gmail-smtp-in.l.google.com has address 209.85.147.114
    3. gmail-smtp-in.l.google.com has address 209.85.147.27
    4. abc@abc:~> /usr/sbin/traceroute gmail-smtp-in.l.google.com
    5. traceroute to gmail-smtp-in.l.google.com (209.85.147.114), 30 hops max, 40 byte packets
    6. 1 192.168.1.7 (192.168.1.7) 0.214 ms 0.198 ms 0.201 ms
    7. 2 203.123.189.33 (203.123.189.33) 1.295 ms 1.638 ms 1.190 ms
    8. Unable to look up 203.123.180.233: Temporary failure in name resolution
    9. 3 203.123.180.233 5.012 ms 4.630 ms 5.520 ms
    10. Unable to look up 203.123.177.6: Temporary failure in name resolution
    11. 4 203.123.177.6 6.178 ms 5.770 ms 5.082 ms
    12. 5 125.16.128.5 (125.16.128.5) 38.943 ms 39.104 ms 35.492 ms
    13. 6 59.145.148.75 (59.145.148.75) 130.965 ms 127.178 ms 124.232 ms
    14. 7 125.21.167.37 (125.21.167.37) 36.922 ms 38.739 ms 36.964 ms
    15. 8 59.145.6.235 (59.145.6.235) 38.769 ms 36.402 ms 37.035 ms
    16. 9 125.21.167.70 (125.21.167.70) 39.104 ms 38.159 ms 36.395 ms
    17. 10 203.208.190.177 (203.208.190.177) 78.637 ms 74.831 ms 74.324 ms
    18. 11 so-2-1-0-0.hkgcw-cr2.ix.singtel.com (203.208.154.38) 264.638 ms * 266.405 ms
    19. 12 72.14.196.5 (72.14.196.5) 280.818 ms 287.523 ms 283.697 ms
    20. 13 216.239.43.68 (216.239.43.68) 292.592 ms 301.439 ms 304.207 ms
    21. 14 209.85.250.88 (209.85.250.88) 312.193 ms 308.870 ms 305.533 ms
    22. 15 66.249.95.170 (66.249.95.170) 319.043 ms 64.233.174.43 (64.233.174.43) 320.645 ms *
    23. 16 216.239.47.235 (216.239.47.235) 321.036 ms * 216.239.47.233 (216.239.47.233) 341.805 ms
    24. 17 216.239.47.237 (216.239.47.237) 453.568 ms 451.889 ms *
    25. 18 72.14.233.37 (72.14.233.37) 464.056 ms 460.247 ms 456.496 ms
    26. 19 209.85.250.57 (209.85.250.57) 451.512 ms 447.714 ms 447.418 ms
    27. 20 72.14.236.146 (72.14.236.146) 457.799 ms 209.85.248.202 (209.85.248.202) 453.523 ms 467.388 ms
    28. 21 wa-in-f114.google.com (209.85.147.114) 447.710 ms * *
    To copy to clipboard, switch view to plain text mode 

    What should I do next????
    Thanks

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

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Looks like the DNS works correctly then. Could you provide a minimal compilable example reproducing the problem?

  11. #11
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Quote Originally Posted by wysota View Post
    Looks like the DNS works correctly then. Could you provide a minimal compilable example reproducing the problem?
    As I told I have copied the same code available in qtassistant in qt3. Anyway here is the link
    http://web.mit.edu/qt_v3.3.3/www/mail-example.html

    Here is the code
    Qt Code:
    1. Smtp::Smtp( const QString &from, const QString &to,
    2. const QString &subject,
    3. const QString &body )
    4. {
    5. socket = new QSocket( this );
    6. connect ( socket, SIGNAL( readyRead() ),
    7. this, SLOT( readyRead() ) );
    8. connect ( socket, SIGNAL( connected() ),
    9. this, SLOT( connected() ) );
    10. connect ( socket, SIGNAL( error ( int ) ),
    11. this, SLOT( slotShowError(int) ) );
    12. mxLookup = new QDns( to.mid( to.find( '@' )+1 ), QDns::Mx );
    13. connect( mxLookup, SIGNAL(resultsReady()),
    14. this, SLOT(dnsLookupHelper()) );
    15. message = QString::fromLatin1( "From: " ) + from +
    16. QString::fromLatin1( "\nTo: " ) + to +
    17. QString::fromLatin1( "\nSubject: " ) + subject +
    18. QString::fromLatin1( "\n\n" ) + body + "\n";
    19. message.replace( message, QString::fromLatin1( "\n" ),
    20. QString::fromLatin1( "\r\n" ) );
    21. message.replace( message, QString::fromLatin1( "\r\n.\r\n" ),
    22. QString::fromLatin1( "\r\n..\r\n" ) );
    23. sender = from;
    24. rcpt = to;
    25. state = Init;
    26. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void Smtp::dnsLookupHelper()
    2. {
    3. QValueList<QDns::MailServer> s = mxLookup->mailServers();
    4. if ( s.isEmpty() && mxLookup->isWorking() )
    5. {
    6. emit status( tr( "Could not find mail server. Please check address." ) );
    7. QMessageBox::warning( qApp->activeWindow(),
    8. tr( "SynsupMail" ),
    9. tr( "Could not find mail server for address:\n\n %1" ).arg( rcpt ) );
    10. QTimer::singleShot( 0, this, SLOT(deleteMe()) );
    11. return;
    12. }
    13. emit status( tr( "Connecting to %1" ).arg( s.first().name ) );
    14. socket->connectToHost( s.first().name, 25 ); //The error occurs here
    15. t = new QTextStream( socket );
    16. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. //The control never comes here
    2. void Smtp::connected()
    3. {
    4. emit status( tr( "Connected to %1" ).arg( socket->peerName() ) );
    5. }
    6. //Displays error status as 0 which is QSocket::ErrConnectionRefused
    7. void Smtp::slotShowError(int errorNo)
    8. {
    9. qDebug("%Error:"+QString("%1").arg((QSocket::Error)errorNo));
    10. }
    To copy to clipboard, switch view to plain text mode 

    Again the code is same as what is given in qtassistant( qt3 ).

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

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    This is hardly what I can call compilable... So what did you change in the example? Does the pure example code function correctly?

  13. #13
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    This is hardly what I can call compilable... So what did you change in the example?
    The code is exactly the same as the example/network/mail. I just copied the entire code without any changes to it.

    Does the pure example code function
    No... It doesnt work.
    Last edited by joseph; 4th July 2007 at 10:20.

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

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Can you connect to gmail-smtp-in.l.google.com using telnet?

    telnet gmail-smtp-in.l.google.com 25

    The server should respond with a smtp greeting, something like:
    220 mx.google.com ESMTP

  15. #15
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Quote Originally Posted by wysota View Post
    Can you connect to gmail-smtp-in.l.google.com using telnet?

    telnet gmail-smtp-in.l.google.com 25

    The server should respond with a smtp greeting, something like:
    220 mx.google.com ESMTP
    I get this
    Qt Code:
    1. abc@abc:~> telnet gmail-smtp-in.l.google.com 25
    2. Trying 209.85.147.27...
    3. telnet: connect to address 209.85.147.27: No route to host
    4. Trying 209.85.147.114...
    5. telnet: connect to address 209.85.147.114: No route to host
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    In that case the problem is not in your application or Qt, but in your machine. It has its routing set up incorrectly. I suggest you contact your network administrator about it.

  17. The following user says thank you to wysota for this useful post:

    joseph (5th July 2007)

  18. #17
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Quote Originally Posted by wysota View Post
    In that case the problem is not in your application or Qt, but in your machine. It has its routing set up incorrectly. I suggest you contact your network administrator about it.
    Hi wysota,
    I told about my problem to network admin. According to him, I cannot directly access the mailservers( like yahoo, gmail etc ) as this would be against security.
    Actually, we dont have any access to mail domains. We can only use lotus notes to send and receive the mails. All other IDs (mails) are blocked. The network admin tells me I can only use 198.168.1.1 IP to send the mail from my workplace using lotus. I tried sending mails to my peers within our intranet using 198.168.1.1 and it succeeded. The mail was sent.

    What is that I can do, without taking my network admin's help, to solve the above problem? or anything I can ask him to make my application work.

    One more important thing is I have my peers working on .NET and they have implemented sending/receving mails. I had a discussion and as I understood, they too are using 198.168.1.1 as bypass address to send and receive the mails.

    Thanks

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

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Then why don't you use that address as well?

  20. #19
    Join Date
    Feb 2006
    Posts
    157
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Unable to resolve the IP address. ( Qt 3.)

    Quote Originally Posted by wysota View Post
    Then why don't you use that address as well?
    OH, Got it...Thanks wysota... It was my network admins problem, fixed it and got it right.

    Thanks wysota again....

Similar Threads

  1. Replies: 2
    Last Post: 14th June 2007, 14:31
  2. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.