[SOLVED]How the server side know if client side disconnect by crash or some unexpect action?
-
-
Should work, but it doesn't sound right that you are not receiving the disconnect signal. Can you post some code showing how you created the TcpSocket object to handle the incoming connection? Here is what I use:
@ socket=this->nextPendingConnection();
connect(socket, SIGNAL(readyRead()), this, SLOT(onReadyRead()), Qt::QueuedConnection);
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onTcpError(QAbstractSocket::SocketError)), Qt::QueuedConnection);
connect(socket, SIGNAL(disconnected()), this, SLOT(onDisconnected()), Qt::QueuedConnection);
@ -
Maybe your problem is related to the problem I'm facing at the moment. Have a look at "this thread":http://qt-project.org/forums/viewthread/38640/. The behaviour seems to differ when the sockets connected to each other loose their connection due to for example a physical disconnect (e.g. network cable unplugged) the client crashing might have the same effect, since he cannot send a disconnect message.
-
[quote author="BBFAG3" date="1392889679"]I connect the SIGNAL and SLOT when it's still empty.......[/quote]
You'll have to forgive me, but what does it mean to be, "empty?" And what is it that is, "empty?"
-
[quote author="drhalftone" date="1392903905"]
[quote author="BBFAG3" date="1392889679"]I connect the SIGNAL and SLOT when it's still empty.......[/quote]You'll have to forgive me, but what does it mean to be, "empty?" And what is it that is, "empty?"[/quote]
I mean...I created a QTcpSocket and connect the slot before I use server.nextPendingConnection()...Forgive my English....My native language is not English