QTcpServer, method incomingConnection() is not invoked



  • Hi;
    I have followed with example from 'Foundaion of Qt Development' book :
    @
    #include <QApplication>
    #include <QTcpServer>
    #include <QThread>
    #include <QTcpSocket>
    #include <QtNetwork>

    //-----------------------------------------------------------
    class Server : public QTcpServer
    {
    public:
    Server();
    protected:
    void incomingConnection(int descriptor);
    };

    Server::Server() : QTcpServer()
    {

    }

    void Server::incomingConnection(int descriptor)
    {
    qDebug()<<"incomingConnection_OK";
    ....
    }
    //----------------------------------------------------------

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    Brevis_Server w;
    
    Server server;
    
    if(!server.listen(QHostAddress::Any, 1111))
    {
          qDebug()<<"Listen error! ";
          return 1;
    }
    w.show();
    
    return a.exec&#40;&#41;;
    

    }

    @
    The method void Server::incomingConnection(int descriptor) is not invoked when client connects to server.
    What's wrong in this example?

    BR


  • Lifetime Qt Champion

    Hi,

    I would say wrong signature. The parameter's not an int but a quintptr


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.