QT QTcpServer listen

864 views Asked by At

i have a question about QT QTcpServer server->listen(QHostAddress, qint16). I have problems with the address.

I tried with QHostAddress("127.0.0.1"), and that worked. I tried with QHostAddress::Any, and that failed (error 10, not supported). I tried with QHostAddress::AnyIPv4, and that failed (same error). I tried with QHostAddress("0.0.0.0"), and that failed, with same error. I tried with the address of the interface, that worked.

NotificationServer::NotificationServer(QObject *parent) : QObject(parent) {     
    server = new QTcpServer(this); 
    connect(server, SIGNAL(newConnection()), this, SLOT(newConnection())); 
    if (!server->listen(QHostAddress::Any, port)) { 
        qDebug() << "Server could not start." << server->serverError(); 
        server = nullptr; 
    } else { 
        qDebug() << "Server started."; 
    } 
}

It seems, that it is not possible making the QTcpServer listen on all interfaces. OS is Linux XUbuntu. How can i make the server listen at all interfaces?

0

There are 0 answers