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. what to specify for END-OF-DATA characters/string
Forum Updated to NodeBB v4.3 + New Features

what to specify for END-OF-DATA characters/string

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 466 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.
  • P Offline
    P Offline
    pingal
    wrote on 7 Mar 2022, 09:54 last edited by pingal 3 Jul 2022, 09:55
    #1

    I've created a clients/server app in which multiple clients share data (text/binary) with the server.
    Are their any character/string pattern I can use to specify "end of data" characters so that the server knows that clientX data is finished (i don't want to close a connection).

    I'm using QT (C++)

    J 1 Reply Last reply 7 Mar 2022, 09:57
    0
    • P pingal
      7 Mar 2022, 09:54

      I've created a clients/server app in which multiple clients share data (text/binary) with the server.
      Are their any character/string pattern I can use to specify "end of data" characters so that the server knows that clientX data is finished (i don't want to close a connection).

      I'm using QT (C++)

      J Offline
      J Offline
      JonB
      wrote on 7 Mar 2022, 09:57 last edited by
      #2

      @pingal
      You have to use or devise your own "protocol" which the client and server both code for. There is noting "in-built in C++" or similar.

      For example, you might terminate a string with a \0 byte, or you might precede it with a length count.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pingal
        wrote on 7 Mar 2022, 09:59 last edited by
        #3

        Although I can use Null or Length count but these bytes can be part of data (e.g. in binary form).

        J J 2 Replies Last reply 7 Mar 2022, 10:03
        0
        • P pingal
          7 Mar 2022, 09:59

          Although I can use Null or Length count but these bytes can be part of data (e.g. in binary form).

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 7 Mar 2022, 10:03 last edited by
          #4

          @pingal start with a length byte(s) end on \0 byte and 2byte crc

          the chance that your binary data fits all 4 criteria by random chance is very minuscule.


          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
          • P pingal
            7 Mar 2022, 09:59

            Although I can use Null or Length count but these bytes can be part of data (e.g. in binary form).

            J Offline
            J Offline
            JonB
            wrote on 7 Mar 2022, 10:08 last edited by
            #5

            @pingal said in what to specify for END-OF-DATA characters/string:

            Although I can use Null or Length count but these bytes can be part of data (e.g. in binary form).

            So if it is arbitrary binary date make your protocol so it always starts with a 1, 2 or 4 byte "count" header, as required for your maximum length, and you are good to go. @J-Hilk suggests such a protocol, with some extra checking at the end if desired.

            1 Reply Last reply
            3
            • P Offline
              P Offline
              pingal
              wrote on 7 Mar 2022, 10:17 last edited by
              #6

              Thanks, that will work.

              1 Reply Last reply
              1

              6/6

              7 Mar 2022, 10:17

              • Login

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