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. TCP Graceful shutdown: Socket shutdown() function missing
Forum Updated to NodeBB v4.3 + New Features

TCP Graceful shutdown: Socket shutdown() function missing

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.0k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    JochenBaier
    wrote on 7 Apr 2014, 19:44 last edited by
    #1

    I have to gracefully close a TCP socket on the client side: Send data, initialize the finish handshake and wait until the the server has finished the handshake. It works without Qt like this:

    @Call shutdown with how=SD_SEND.
    Call recv() until the function completes with success and indicates zero bytes were received. If SOCKET_ERROR is returned, then the graceful disconnect is not possible.
    Call closesocket().@

    from: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740481(v=vs.85).aspx
    more infos: http://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable

    I tried it with:

    @disconnectFromHost ();
    read();@

    But this doesn't work of course. Is this possible with QTcpSocket? disconnectFromHost() only uses closesocket(). So if the link is lost all functions will still return success but zero data will be send.

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Apr 2014, 19:54 last edited by
      #2

      Hi,

      Interesting question while a bit low level, I think you should bring it to the interest mailing, you'll find Qt's developers/maintainers there (this forum is more user oriented)

      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
      • J Offline
        J Offline
        JochenBaier
        wrote on 8 Apr 2014, 17:10 last edited by
        #3

        Hi, SGaist,

        thanks for pointing me to the interest mailing list.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on 8 Apr 2014, 17:57 last edited by
          #4

          I am wondering why you are not deleting the object after your disconnectFromHost ?

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0

          1/4

          7 Apr 2014, 19:44

          • Login

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