Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTcpServer in console app don't emit newConnection() signal
Viranis last edited by
I am new both to Qt and networking. I created class inheriting QObject:
In class constructor I wrote:
server = new QTcpServer(this);
QObject::connect(server, SIGNAL(newConnection()), this, SLOT(newPlayerRegistration()));
The problem is when I try to connect to server via telnet or nc. newConnection() signal is not emited. @server->isListening(); returns true@
returns appropriate values.
I don't block event queue.
Also is it possible to use Qt networking with pthreads passing QTcpSocket (I have to use pthreads, this is my course assignment)?
ckakman last edited by
Just to make sure, how does the main() function look like? You need to have a QCoreApplication:
You can't pass QTcpSocket to another thread. But you can reimplement the protected incomingConnection() function of QTcpServer in a derived class, pass the socket descriptor to another thread and create the QTcpSocket there. I don't know whether the signal-slot connections would work in this case.