Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is Mac-Hack in QAbstractSocket still required?
Forum Update on Monday, May 27th 2025

Is Mac-Hack in QAbstractSocket still required?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qtdude_bs
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved