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 406 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 last edited by pingal
    #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++)

    JonBJ 1 Reply Last reply
    0
    • P pingal

      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++)

      JonBJ Online
      JonBJ Online
      JonB
      wrote on 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 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.HilkJ JonBJ 2 Replies Last reply
        0
        • P pingal

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

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on 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

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

            JonBJ Online
            JonBJ Online
            JonB
            wrote on 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 last edited by
              #6

              Thanks, that will work.

              1 Reply Last reply
              1

              • Login

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