Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Is Mac-Hack in QAbstractSocket still required?
qtdude_bs last edited by
I have a little headache with the implementation of QAbstractSocket, especially with the code on the lines 2662 to 2689. According to documentation this was added to prevent some issues with the socket implementation on a mac. In my case it causes some problems on Windows.
I use a QTcpSocket to send the content of a software update to some not-so-fast embedded device. In my implementation I just read the content of the software update from a file into a QByteArray, then write that byte array at once into the connected QTcpSocket and immediately calling disconnectFromHost(). There is also a slot connected to the disconnected signal which displays an "Update done" message on the GUI.
From what I understood in the documentation the disconnected() signal should only be emitted, once the whole TCP content from the buffers has been transferred to the embedded device and the embedded device also closed the socket from its side. But it turns out, that this signal is emitted much earlier. When it is emitted and therefore the GUI shows the "Update done" message, the underlying socket is still transferring the content, which is odd in the best case and dangerous in the worst case, because I risk to install an incomplete firmware image on the embedded device in this case.
So after some research, I found these suspicious mentioned code lines, which effectively forcefully close the socket if it has been lingering in the "Closing" state for 2 seconds.
So my questions are basically
- is this hack still required?
- is it possible to apply this hack only on Mac? (it is obviously dealing with a mac problem and I had the problem on a Windows machine)
- is it possible to make this 2sec timeout configurable?
I hope someone can help me with this issue...
My Environment: I use Qt 5.0.2 with a Visual Studio 2010 compiler
Hi and welcome to devnet,
I recommend you to post this question on the qt-interest mailing list. This forum is not very often read by Qt developer so you would have better chance on getting a useful answer there.
Did you also check the "bugreport":https://bugreports.qt-project.org/issues/ site to see if someone else talked about it ?