I try to implement my own server class inheriting QTcpServer
.
here is the simple code i try to run :
server.cpp
MyServer::MyServer(QObject *parent) :
QTcpServer(parent)
{
}
void MyServer::incomingConnection(qintptr handle)
{
qDebug() << "Incomming";
SecureSocket * socket = new SecureSocket(this);
connect(socket, SIGNAL(StatusMessage(QString)), SIGNAL(StatusMessage(QString)));
socket->Process(handle);
}
main.cpp
MyServer serv;
if(serv.listen(QHostAddress::Any,1080))
console.WriteLine("Listenning on port 1080..."); //Console it's just a class to display message (here it's a simple qDebug())
else {
console.WriteLine("Unable to start server");
}
QThread serverThread;
QObject::connect(&serverThread,SIGNAL(finished()),&serverThread,SLOT(deleteLater()));
serv.moveToThread(&serverThread);
My problem is that I never reach the incommingConnection
(I try a https://localhost:1080
in my browser as test client) and I actually don't understand why. The server seems to listen properly because as long as the application run, my browser try to load the page, and set a loading error when I quit the application.
P.S. : It's a console application