QTcpServer not emiting signals
- by Timothy Baldridge
Okay, I'm sure this is simple, but I'm not seeing it:
HTTPServer::HTTPServer(QObject *parent) :
QTcpServer(parent)
{
connect(this, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
}
void HTTPServer::acceptConnection()
{
qDebug() << "Got Connection";
QTcpSocket *clientconnection = this->nextPendingConnection();
connect(clientconnection, SIGNAL(disconnected()), clientconnection, SLOT(deleteLater()));
HttpRequest *req = new HttpRequest(clientconnection, this);
req->processHeaders();
delete req;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
HTTPServer http(0);
http.listen(QHostAddress::Any, 8011);
qDebug() << "Started: " << http.isListening() << http.serverAddress() << ":" << http.serverPort();
return a.exec();
}
According to the docs my acceptConnection() slot should be called whenever there is a new connection. I can connect into this tcp port with a browser or telnet, and I don't get any errors, so I know it's listening, execution never goes to my acceptConnection() function?
And yes my objects inherit from QObject, I've just stripped the code down to the essential parts above.
There's no build errors....