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 vs UDP
Forum Updated to NodeBB v4.3 + New Features

TCP vs UDP

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 734 Views 2 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.
  • S Offline
    S Offline
    sirAnton
    wrote on last edited by
    #1

    Re: Why QTcpSocket::waitForBytesWritten returns immediately

    Hello, as described in the referenced tread i can not be sure that my TCP packet is arrived. I must give me an acknowledge from the receiver.
    Why i use then TCP and not UDP ?
    Sorry for these "stupid?" question...

    J.HilkJ 1 Reply Last reply
    0
    • S sirAnton

      Re: Why QTcpSocket::waitForBytesWritten returns immediately

      Hello, as described in the referenced tread i can not be sure that my TCP packet is arrived. I must give me an acknowledge from the receiver.
      Why i use then TCP and not UDP ?
      Sorry for these "stupid?" question...

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @sirAnton said in TCP vs UDP:

      Hello, as described in the referenced tread i can not be sure that my TCP packet is arrived.

      The Transmission Control Protocol (TCP) detects packet loss and performs retransmissions to ensure reliable messaging
      

      The idea behind tcp is no packet loss. For UDP however, there is absolutely no guarantee that your packet arrived


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      JonBJ 1 Reply Last reply
      3
      • J.HilkJ J.Hilk

        @sirAnton said in TCP vs UDP:

        Hello, as described in the referenced tread i can not be sure that my TCP packet is arrived.

        The Transmission Control Protocol (TCP) detects packet loss and performs retransmissions to ensure reliable messaging
        

        The idea behind tcp is no packet loss. For UDP however, there is absolutely no guarantee that your packet arrived

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @J-Hilk
        Question: As per the referenced topic and @aha_1980's answer there

        How can i know when data sent fully?

        IMHO you cannot.

        Please note that in a distributed network it does not mean much when a TCP packet is sent out, it can have a long way until it's destination. It can even be re-send if the sender does not get an ACK from the receiver.
        What you can do, is to give an acknowlegde from the receiver side once it received the data and evaluate that on the sender side.

        If TCP protocol knows to re-send if it does not get TCP-level ACK from receiver, why do "you" have to write code at receiver side to send back message for completion? Why can't/doesn't TCP let you know when it does receive that ACK, so that you'd know it didn't need retry and had arrived?

        J.HilkJ 1 Reply Last reply
        0
        • JonBJ JonB

          @J-Hilk
          Question: As per the referenced topic and @aha_1980's answer there

          How can i know when data sent fully?

          IMHO you cannot.

          Please note that in a distributed network it does not mean much when a TCP packet is sent out, it can have a long way until it's destination. It can even be re-send if the sender does not get an ACK from the receiver.
          What you can do, is to give an acknowlegde from the receiver side once it received the data and evaluate that on the sender side.

          If TCP protocol knows to re-send if it does not get TCP-level ACK from receiver, why do "you" have to write code at receiver side to send back message for completion? Why can't/doesn't TCP let you know when it does receive that ACK, so that you'd know it didn't need retry and had arrived?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @JonB I'm by no means on expert on this, but I would assume the answer is in the API / Standard and that it's not defined there.

          The OS manages the data transaction and resends the packet if necessary.

          Therefore the acknowledgment is not passed along to the application level.
          šŸ¤·ā€ā™‚ļø


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          JonBJ 1 Reply Last reply
          2
          • J.HilkJ J.Hilk

            @JonB I'm by no means on expert on this, but I would assume the answer is in the API / Standard and that it's not defined there.

            The OS manages the data transaction and resends the packet if necessary.

            Therefore the acknowledgment is not passed along to the application level.
            šŸ¤·ā€ā™‚ļø

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @J-Hilk said in TCP vs UDP:

            Therefore the acknowledgment is not passed along to the application level.

            Yeah, but I want it to be! Then we could keep the OP happy :)

            J.HilkJ 1 Reply Last reply
            1
            • JonBJ JonB

              @J-Hilk said in TCP vs UDP:

              Therefore the acknowledgment is not passed along to the application level.

              Yeah, but I want it to be! Then we could keep the OP happy :)

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @JonB said in TCP vs UDP:

              Yeah, but I want it to be! Then we could keep the OP happy :)

              well, how good are you at driver coding ?


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              3
              • Kent-DorfmanK Offline
                Kent-DorfmanK Offline
                Kent-Dorfman
                wrote on last edited by
                #7

                I think the side question about TCP level ACK and transaction ACK goes to the function of TCP transactions. Since TCP is itself a stream/session protocol there is no implicit understanding of an application packet. That is left up to the application layer to define and implement a transaction protocol over top of TCP. If the OP simply wants guaranteed discrete messages then sometimes UDP with some application level retries is better than defining an application layer TCP protocol that frames the data as expected, IMHO.

                1 Reply Last reply
                3

                • Login

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