QTcpServer in console app don't emit newConnection() signal
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)?
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.