QTcpServer not emiting signals

Posted by Timothy Baldridge on Stack Overflow See other posts from Stack Overflow or by Timothy Baldridge
Published on 2010-04-06T20:10:15Z Indexed on 2010/04/06 20:13 UTC
Read the original article Hit count: 578

Filed under:
|

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....

© Stack Overflow or respective owner

Related posts about qt4

Related posts about c++