PDA

View Full Version : Problem on connection establishment with QTcpSocket



Mascetti1987
22nd November 2011, 11:39
I 'm trying to make up a socket connection performing the following steps:

TcpClient::TcpClient() : m_socket(this) {
bool ok;
ok = QObject::connect(&m_socket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(displayError(QAbstractSocket::SocketError)));
Q_ASSERT(ok);
ok = QObject::connect(&m_socket, SIGNAL(connected()),
this, SLOT(handleConnection()));
Q_ASSERT(ok);
}


where the m_socket is defined as

QTcpSocket m_socket;


and this is not doing any problem on a Unix based plaform.

If I try to execute the same application in a Windows platform, it crashes and i don't know why.
No compile error was find, but when I launch the app, it freezes when i define the object used to send TCP messages:

ncp::TcpClient clnt;

Does anyone have any ideas why it crashes?
Thank you in advice.

Mirko.

Mascetti1987
23rd November 2011, 10:30
In particular the problem resides in

ok = QObject::connect(&m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));

i think on errror function (and the same on the connected 2 lines after).

Is possible that there is an error addressing this function?
Any ideas to solve it?

Mirko.