read TCP stream issue

Hi,
Maybe you will be able to give me some tips 😅
I am writting a tool using already created API. The creator of the api doesn't know c# so he isn't able to help me with that issue (API is written in C++ but it should work fine with c# too).
In short - tool sends json messages using TCP socket. Messages are terminated with '\1' character or 0x01 byte (so one "packet" can in fact be stored in 2 <or more> messages received from a bot).

and this is the part I have no idea how to handle.
I wrote something like that:
//function to receive messages from tcpserver
while (true)
{
    byte[] numArray = new byte[TCPClient.ReceiveBufferSize + 1];
    TCPClientStream.Read(numArray, 0, TCPClient.ReceiveBufferSize);
    string[] msg = Strings.Split(Encoding.UTF7.GetString(numArray), "\u0001");
    ...
    later json deserialize etc
}

but it's not reading packets which are stored in more than one tcp message.

do you have any ideas how can I fix that?
I made a tool with QT and c++..and ok. it works fine. but I personally hate c++ and "upgrading" this tool is a horror for me.

With C# it seems to be not reading part of the messages, which should be handled. I checked that and seems to be missing about 30% of the packets.

There is no official c# api...but this kind of api should be possible to work with any language which supports JSON and TCP sockets.

thanks for any tip in advance and have a nice day!
Was this page helpful?