IPC with QLocalSocket UnconnectedState not called
-
Hi,
I am having a weird issue with QLocalSocket while trying to communicate between two applications. This is my first time using QLocalSocket. I have subclassed a QLocalSocket and use moveToThread() to have all of my packet parsing done in the background. The stateChanged() signal connected like so in my QMainWindow:
@
// local socket class
qRegisterMetaTypeQAbstractSocket::SocketState("QAbstractSocket::SocketState");
qRegisterMetaTypeQLocalSocket::LocalSocketState("QLocalSocket::LocalSocketState");
socket = new LocalSocket();
connect(socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)), this, SLOT(socketStateChanged(QLocalSocket::LocalSocketState)));... other connections to connect to the server, send recv data, ect.
...
...// local socket thread socketThread = new QThread(this); socket->moveToThread(socketThread); // move the socket subclass to the thread socketThread->start(); // start the thread
@
where my slot is as follows:
@
/*
// socket state changed (private slot)
*/
void MainWindow::socketStateChanged(QLocalSocket::LocalSocketState state)
{
// check the socket state
switch (state){
// unconnected state
case QLocalSocket::UnconnectedState: {
// start the timer to connect
if (!timerConnection->isActive())
timerConnection->start();// set disconnected ui setDisconnectedUI(); break; } // connected state case QLocalSocket::ConnectedState: { // set the connected ui setConnectedUI(); break; } }
}
@I get the QLocalSocket::ConnectingState and QLocalSocket::ConnectedState initially after I call connectToServer() (which both sides start data transmission successfully), but when I kill the process running the server, I never receive a QLocalSocket::UnconnectedState.
I know in Linux, the QLocalSocket uses a file in /tmp/'server_name' for the IPC, is there something on the server side that needs to happen when the server cleanup happens? (after the process is killed)