
Originally Posted by
wysota
I don't know, it's just a thing to check to identify the problem. Maybe the port is blocked or something like that.
Do you use the same machine for the client and the server?
Does the vanilla client-server combination work?
Yes, they are on the same machine. This is the plain vanilla client / server, and they do not work. I then added slots to the client for when the connection is done, and I put breakpoints in those methods, but they are never reached:
connect (tcpSocket, SIGNAL(connected ()), this, SLOT(connectionComplete ()));
connect (tcpSocket, SIGNAL(hostFound ()), this, SLOT(hostFoundComplete ()) );
connect (tcpSocket, SIGNAL(connected ()), this, SLOT(connectionComplete ()));
connect (tcpSocket, SIGNAL(hostFound ()), this, SLOT(hostFoundComplete ()) );
To copy to clipboard, switch view to plain text mode
Next, I added a button to get the status of the client connection and supposedly the connection is in the "connected state". I even looked at netstat and the connection is established, but no data is exchanged.
connect (statusButton, SIGNAL(clicked()), this, SLOT(getSocketState ()) );
...
void Client::getSocketState ()
{
switch (tcpSocket->state ())
{
status2Label->setText (tr("unconnected state"));
break;
status2Label->setText (tr("host lookup state"));
break;
status2Label->setText (tr("connecting state"));
break;
status2Label->setText (tr("connected state"));
break;
status2Label->setText (tr("bound state"));
break;
status2Label->setText (tr("Closing state"));
break;
status2Label->setText (tr("Listening state"));
break;
default:
status2Label->setText (tr("Unknown state"));
break;
}
}
connect (statusButton, SIGNAL(clicked()), this, SLOT(getSocketState ()) );
...
void Client::getSocketState ()
{
switch (tcpSocket->state ())
{
case QAbstractSocket::UnconnectedState:
status2Label->setText (tr("unconnected state"));
break;
case QAbstractSocket::HostLookupState:
status2Label->setText (tr("host lookup state"));
break;
case QAbstractSocket::ConnectingState:
status2Label->setText (tr("connecting state"));
break;
case QAbstractSocket::ConnectedState:
status2Label->setText (tr("connected state"));
break;
case QAbstractSocket::BoundState:
status2Label->setText (tr("bound state"));
break;
case QAbstractSocket::ClosingState:
status2Label->setText (tr("Closing state"));
break;
case QAbstractSocket::ListeningState:
status2Label->setText (tr("Listening state"));
break;
default:
status2Label->setText (tr("Unknown state"));
break;
}
}
To copy to clipboard, switch view to plain text mode

Originally Posted by
wysota
If you run the server, are you able to telnet to the port it is running on?
When I telnet to the server my server breakpoints are not hit, but if I close the server, my telnet window sees the closure. It is as though the connection is never 'accepted'?
Thanks.
DP
Bookmarks