Results 1 to 19 of 19

Thread: QTcpSocket::connectToHost

  1. #1
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default QTcpSocket::connectToHost

    Hello All,

    I am trying to connect using QTcpSocket::connectToHost. This is working fine when I provide host IP (tcpSocket->connectToHost("xx.xx.xx.xx".80)).

    But not working when I provide host name (tcpSocket->connectToHost("www.xxx.com".80)).
    It seems it not resolving host name.
    What can I do ?

  2. #2
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default Re: QTcpSocket::connectToHost

    from Qt's document, it should support host name,
    Could you try : "At any point, the socket can emit error() to signal that an error occurred. "
    to get detailed error information?

  3. #3
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    Its always giving same error. "host not found".

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    I found one more problem with QTcpSocket class.
    When we set proxy settings in this class, we need to call QTcpSocket::setProxy(QNetworkProxy("HOST NAME", PORT));

    But this is not working at all. Means its setting the proxy but not using that.
    It means
    case 1:
    Proxy server is there("xyz",3128).
    QTcpSocket soc;
    soc.setProxy(QNetworkProxy("xyz", 3128));
    soc.connectToHost("100.100.100.100", 80);

    case 2:
    Proxy server is not there.
    QTcpSocket soc;
    soc.connectToHost("100.100.100.100", 80);

    case 3:
    Proxy server is there("xyz",3128).
    QTcpSocket soc;
    soc.setProxy(QNetworkProxy("xyz", 3128));
    soc.connectToHost("www.yahoo.com", 80);

    case 4:
    Proxy server is not there.
    QTcpSocket soc;
    soc.connectToHost("www.yahoo.com", 80);



    In this scenario only case 2 will work.
    Case 2 will only work because there is no proxy server and we provide IP address instead of host name in function connectToHost.



    So there are 2 issues with TCP Socket.

    1. Resolving host name e.g soc.connectToHost("www.yahoo.com", 80);
    2. Use proxy settings done by e.g. soc.setProxy(QNetworkProxy("xyz", 3128));
    Last edited by yogeshgokul; 11th September 2008 at 14:38.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    Does it work if you specify the proxy's IP address instead of its name? It looks like name resolution doesn't work on your system.

  6. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    I also thought that and tried already but no luck. I forget to mention that case here.

  7. #7
    Join Date
    Apr 2009
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTcpSocket::connectToHost

    Today I encounter the same problem!if I use the host name,always the error:host not found!But when I use the IP address,such as :xx.xx.xx.xx,it work perfectly!I don‘t know why

  8. #8
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    hey yogesh!! ... are u still stuck with the problem we faced at PSPL??? as far as i remember when we were coding SM2 and working on upload/download muhurta u faced the same problem...

    remember PM told that we have hardcoded the website ip in fndef file ...

    this remided me of old days... jeevan me chai gala sek kar peene ka maja he kuch aur tha..


  9. #9
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    Yes this is same problem, but now resolved in latest qt build 4.5.X. ha yaar wo din to mast hi the jab appan 3 din me apps bana ke fek dete the.. iski maka naka kar dete the

  10. #10
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    mujhe to ab bhi lagta hai ki hum 3 din me app bana ke pani ka gilaas manager ke muh pe mar sakte hain

  11. #11
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    aur jab wo apni aankhe mal raha hoga to kya kehna/karna chahiye?

  12. #12
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    uska haath aakho pe se hata ke, kheech ke lappad laga te hai,

  13. #13
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    bilkul sahi jawab.. arre kukur tu to bilkul nahi badla re

  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: QTcpSocket::connectToHost

    Guys, after all this is an English spoken site. If you want to talk in private, use the private messaging system.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    TheIndependentAquarius (11th April 2012)

  16. #15
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    inbox size is too very small. we are long lost friends, so just over excited i think.

  17. #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: QTcpSocket::connectToHost

    Quote Originally Posted by MrDeath View Post
    inbox size is too very small.
    We're low on resources. It's either private messages or forum threads with attachments.
    we are long lost friends, so just over excited i think.
    Ever heard of emails?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. #17
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    Quote Originally Posted by wysota View Post
    We're low on resources. It's either private messages or forum threads with attachments.
    oh.. okay.

    Quote Originally Posted by wysota View Post
    Ever heard of emails?
    the place where i am currently in has blocked internet. Ever heard of the great (Fire)Wall of china?

  19. #18
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    You mean there is the same fire wall in Taiwan as in China mainland??
    I thought only our mainland has that fire wall

  20. #19
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTcpSocket::connectToHost

    no ... i ment that in our office there is a firewall, we dont have access to anything. only 10-15 websites are allowed.

    but there is some degree of firewall in taiwan i think... i cannot open sites ending with .mil(millitary?) at public computers.

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.