what to specify for END-OF-DATA characters/string
-
wrote on 7 Mar 2022, 09:54 last edited by pingal 3 Jul 2022, 09:55
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++)
-
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++)
wrote on 7 Mar 2022, 09:57 last edited by@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. -
wrote on 7 Mar 2022, 09:59 last edited by
Although I can use Null or Length count but these bytes can be part of data (e.g. in binary form).
-
Although I can use Null or Length count but these bytes can be part of data (e.g. in binary form).
@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.
-
Although I can use Null or Length count but these bytes can be part of data (e.g. in binary form).
wrote on 7 Mar 2022, 10:08 last edited by@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.
-
wrote on 7 Mar 2022, 10:17 last edited by
Thanks, that will work.
6/6