slcotter
9th May 2007, 01:59
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.
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.