QWebSocketServer moving new connections to a own thread



  • Hi,

    I'm developing a client-server application. Therefore I'm using the QWebSocket class to achieve binary transparency for the sent messages. To listen for incoming connections I'm using the QWebSocketServer class which works pretty nice so far. (basically the echoclient and echoserver example)

    Now my question:
    I would like to have a thread for every incoming connection (the QTcpServer class does support this) but the documentation says the returned QWebSocket* pointer by nextPendingConnection() cannot be used from another thead. Is this somehow possible and how?



  • @void QCNetHTTPServer::incomingConnection(int socketDescriptor) {
    QThNetHTTPServerConn *ThNetHTTPServerConn= new QThNetHTTPServerConn(this, socketDescriptor);
    ThNetHTTPServerConn->start();

    ....

    void QThNetHTTPServerConn::run() {
    QTcpSocket *QTSClient= new QTcpSocket();
    QTSClient->setSocketDescriptor(socketDescriptor);
    @



  • Correct for the QTcpSocket and QTcpSocketServer classes.
    But I'm asking for the QWebSocket and QWebSocketServer classes.

    QWebSocketServer does not have the method incomingConnection. So I can't overwrite it, or am I seeing this wrong?

    Any further ideas?



  • Really I didn't know that QWebSocket existed and I don't know what QWebSocket can do.
    For my own programs that need to exchange data over network, I normally use a custom http server and client components.
    The server component uses QThread and is written on pure Qt code. I can use it for a normal http server activity and for mpeg tunnel.
    Is not so hard to write.

    What do you have to do exactly?



  • Websockets provide the features I need without further implementation:

    • binary transparent data transfer
    • bidirectional
    • TCP based

    HTTP is missing the bidirectional feature.
    TCP is missing the binary transparent data transfer feature.

    Therefore I want to use Websockets instead of implementing custom components to TCP sockets or HTTP transfer classes.



  • Bump for interest.
    QWebsocket actually has a private constructor where it accepts an QTcpSocket pointer - but sadly, it's private.


  • Moderators

    @Xandl said:

    Bump for interest.
    QWebsocket actually has a private constructor where it accepts an QTcpSocket pointer - but sadly, it's private.

    If you believe this is a feature that should be made public, submit a request to https://bugreports.qt.io/


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.