Skip to content
  • 0 Votes
    3 Posts
    181 Views
    R

    The server page was not loading and the issue was I was using the server's newConnection() signal to immediately write the html page to the client. But you have to wine and dine the client first. I ended up connecting the newConnection() signal to a set up function:

    void Server::handleConnection() { QTcpSocket* client = nextPendingConnection(); //client->setSocketOption(QAbstractSocket::KeepAliveOption, 0); QObject::connect(client,&QTcpSocket::readyRead,this,[=](){ handleRequest(client); }); }

    You can then write the HTML content to the client in handleRequest()

  • 0 Votes
    2 Posts
    694 Views
    raven-worxR

    @Saman19
    You may want to check out Cutelyst if you want to support the HTTP protocol.

    If you do not need to rely on HTTP, but just want to receive JSON (or any custom protocol), take a look at QTcpServer examples.