Always via TCP (via ordinary sockets) transmitted serialized data in binary form. The message began with a header and data about the length of the message. But here one of the customers wants the data to be transmitted in the form of JSON. And my side is only server. How would I see two options:

1) Write the header and length of the message inside the JSON string (at the very beginning). The disadvantage is that it is inconvenient to form a string, because the length is still unknown, but I would like to write it down already. But it can be solved - just uncomfortable.

2) Run through the entire buffer in search of the end of the JSON string. Roughly speaking, check the contents of the buffer for validity. The disadvantage is a very large overhead in my opinion.

So the question itself is, can anyone come across the transfer of the JSON string "as is" over TCP using ordinary sockets and has experience of implementation.

  • Comments are not intended for extended discussion; conversation moved to chat . - Nick Volynkin

0