Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt incomingConnections not called

Tags:

c++

tcp

qt

I have compiled Qt's Trip Planner example that uses QTcpSocket and QTcpServer to create a client and server.

The problem is, the server's incomingConnection() slot is not being called. Even though the client connects to the server successfully. Therefore, the socket's readyRead() signal is never emitted and the client gets no data back.

tripserver.cpp

TripServer::TripServer(QObject *parent)
    : QTcpServer(parent)
{
}


void TripServer::incomingConnection(int socketId)
{
    qDebug() << "Incoming Connection";
    ClientSocket *socket = new ClientSocket(this);
    socket->setSocketDescriptor(socketId);
}

If I add a newConnection() slot, it gets called. So what is going on?

like image 697
Quaxton Hale Avatar asked Aug 23 '14 02:08

Quaxton Hale


1 Answers

Found my answer.

The parameter list has changed since Qt 4.8.1

http://qt-project.org/doc/qt-5.0/qtnetwork/qtcpserver.html#incomingConnection

void TripServer::incomingConnection(qintptr socketId){}

like image 141
Quaxton Hale Avatar answered Oct 04 '22 03:10

Quaxton Hale