Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. IPC with QLocalSocket UnconnectedState not called
Forum Updated to NodeBB v4.3 + New Features

IPC with QLocalSocket UnconnectedState not called

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vezprog
    wrote on last edited by
    #1

    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)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved