Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QWebSocket - access bytesToWrite() to detect overload



  • Hi,

    I want to push lots of data over a qwebsocket connection. Unfortunately I cannot detect a network overload since there is no such thing as "bytesToWrite" as in QAbstractSocket. Is there any way to access the underlying QTcpSocket from a QWebSocket ?

    Thanks.





  • I don't think so because I don't know the real payload that will be sent over the socket, as far as I understood the documentation bytesWritten will give me the length including all protocol and encryption overhead, not just the amount of bytes I sent initially.


  • Lifetime Qt Champion

    @s_b_ said in QWebSocket - access bytesToWrite() to detect overload:

    I don't think so because I don't know the real payload that will be sent over the socket, as far as I understood the documentation bytesWritten will give me the length including all protocol and encryption overhead, not just the amount of bytes I sent initially.

    But this is only the indication that the bytes are written from QWebSocket to the operating system buffers. It is no indication that the data is sent to network, and especially no indication that the data has arrived at its destination.

    Which kind of network overload do you have in mind? The network will of course not overload, it will only be filled to the max. Do you think of a receiver overload? Or do you want to preserve network capacity?



  • Basically I need to reduce the amount of data that is pushed to QWebSocket if the underlying components (Qt's ringbuffer, TCP/IP stack, receiver) are all saturated. On windows e.g. I would check if WSASend would return WSAEWOULDBLOCK / WSAENOBUFS, meaning send buffers are full, acknowledges are pending and so on...


  • Lifetime Qt Champion

    @s_b_

    Ok, if you really think that is necessary, then feel free to modify QWebSocket so you get access to QTcpPort. It would be a tailor-made solution anyway.

    [Edit] make sure your licence allows this modification, though.



  • @aha_1980 thanks for your help, I'm still in the phase of investigating what is happening on the network.


Log in to reply