Important: Please read the Qt Code of Conduct -

[Solved] QTcpServer.listen() always returns false

  • Hi all,

    I'm working on a project about a basic TCP connection. At present, I'm developing the server. The constructor code is as follows:

    @Server::Server(QObject* parent): QObject(parent)
    connect(&server, SIGNAL(newConnection()), this, SLOT(acceptConnection()));

    if (!server.listen(QHostAddress::Any, 888))
    qDebug("Server could not start");


    The problem is that the listen function is always returning false..
    What can be the issue please?

    Newbie, I'm working on Fedora16 in Virtual Machine
    QtCreator 2.3.1


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You are trying to use a system reserved port number, that's why it fails. You should use something over 1023 for your application, or let QTcpServer get one port automatically.

  • Yes that's it! Thanks a lot

Log in to reply