Results 1 to 5 of 5

Thread: QTcpSocket and Qt 4.2.3

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTcpSocket and Qt 4.2.3

    Some time ago I began developing a socket-using program with Qt 4.2.2. I've recently switched to a new computer and installed the more recent Qt 4.2.3.

    My code compiles and runs under both systems, but the tcp socket doesn't function properly on the 4.2.3 system.

    The code is:

    #include <QApplication>
    #include <QTcpSocket>
    #include <iostream>

    int main(int argc, char* argv[])
    {
    QApplication app(argc, argv);
    QTcpSocket *internet = new QTcpSocket;
    internet->connectToHost("xxx.xxx.xxx.xxx", xxxx);
    std::cout << "waiting up to 10s for connection..." << std::endl;
    if(internet->waitForConnected(10000))
    std::cout << "Connected to host!" << std::endl;
    else
    {
    std::cout << "Could not connect to host!" << std::endl;
    exit(0);
    }
    //more code here//
    }
    Under 4.2.3, I always exit after "Could not connect to host!" while on my 4.2.2 setup, the connection is established properly.

    This is the most basic socket implementation, right? This shouldn't be hard to implement, so I must be doing something stupid. What's my mistake?

    Thanks for your time.
    Last edited by slcotter; 9th May 2007 at 01:01. Reason: formatting & shortened snippet

Similar Threads

  1. Tell QTcpSocket which interface to use
    By rianquinn in forum Qt Programming
    Replies: 7
    Last Post: 23rd December 2010, 17:28
  2. How do I use QTcpSocket properly ?
    By mnemonic_fx in forum Qt Programming
    Replies: 13
    Last Post: 29th March 2007, 20:33
  3. Problems with QThread and QTcpSocket
    By cookiem in forum Qt Programming
    Replies: 6
    Last Post: 2nd November 2006, 08:25
  4. Problem with QTcpSocket and QDataStream
    By Valheru in forum Qt Programming
    Replies: 4
    Last Post: 16th September 2006, 13:08
  5. QTcpSocket disconnection problem
    By erdi in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2006, 21:50

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
  •  
Qt is a trademark of The Qt Company.