Results 1 to 2 of 2

Thread: QLocalServer incomingConnection method never calls, but newConnection signal sent

  1. #1
    Join Date
    Sep 2013
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QLocalServer incomingConnection method never calls, but newConnection signal sent

    I am creating a simple QSocketServer in Qt. The socket starts to listen, but the incomingConnection method never seems to run. Can someone explain what is wrong here?

    in main:
    Qt Code:
    1. m_pipeserver = new PipeServer(this);
    2. if (m_pipeserver->listen("test.sock")) {
    3. qDebug() << "STARTED";
    4. }
    To copy to clipboard, switch view to plain text mode 

    in pipeserver.h
    Qt Code:
    1. class PipeServer : public QLocalServer
    2. {
    3. Q_OBJECT
    4. public:
    5. PipeServer(Controller *parent = 0);
    6. protected:
    7. void incomingConnection(qintptr socketDescriptor);
    To copy to clipboard, switch view to plain text mode 
    pipeserver.cpp
    Qt Code:
    1. PipeServer::PipeServer(Controller *parent)
    2. {
    3. }
    4. void PipeServer::incomingConnection(qintptr socketDescriptor)
    5. {
    6. qDebug() << "NEW CONNECTION";
    7. // etc...
    To copy to clipboard, switch view to plain text mode 

    I see the STARTED message, but never see the NEW CONNECTION when I run:

    socat -v READLINE unix-connect:/tmp/test.sock

    Just for fun I hooked a slot method onto the newConnection signal and that method DOES fire when I connect. So why isn't the incomingConnection method firing?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLocalServer incomingConnection method never calls, but newConnection signal sent

    1. The parameter type for incomingConnection() is quintptr not qintptr, so your function is not overriding the existing virtual. Typically you process new connections in response to the newConnection() signal, not by overriding the incomingConnection() method.
    2. "test.sock" and "/tmp/test.sock" may not be the same socket.

Similar Threads

  1. Problem with Qt Netbeans, method calls
    By 0_Azerty_0 in forum Qt Programming
    Replies: 2
    Last Post: 10th April 2013, 16:36
  2. Replies: 4
    Last Post: 3rd June 2012, 06:45
  3. QtcpServer newConnection() signal
    By LynneV in forum Qt Programming
    Replies: 0
    Last Post: 2nd November 2011, 21:57
  4. Can we make the signal calls synchronous??
    By yogesh in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2009, 10:37
  5. Doxgen call graphs also for signal-slot calls?
    By zavulon in forum Qt Programming
    Replies: 0
    Last Post: 25th September 2008, 15:29

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.