PDA

View Full Version : QTcpSocket disconnected signal handling



hashimov
6th February 2012, 09:06
Hi.

I wrote some programm which uses QTcpServer. I inherit some class from QTcpServer and in handleNewConnection method wrote something like this.


while (hasPendingConnections())
{
QTcpSocket* client = nextPendingConnection();
connect(client, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
}

in clientDisconnected() slot i wrote something, for example printf("disconnected");

And then i connect to this server using my Android Telnet client. When i connect to server using Windows Telnet client and then disconnected the clientDisconnected() method works and prints. But when i connect to Android Telnet client and then disconnect my phone from wifi, nothing prints, clientDisconnected() method not works.

I have write another program which recieves packets from gprs. When mobile phone can not send or no gprs connection with operatorServer does not disconnected old connection, and mobile phone tries connect again. Same problem in this case.

What is problem? Why is does not works?

wysota
6th February 2012, 13:15
Try:

printf("disconnected\n");

hashimov
13th February 2012, 05:02
Problem is not in "\n" end of string. Problem is in when clients loses internet connection for example when client is in place where no GSM/GPRS or 3G connection, QTcpServer don't no that client disconnected.