C#C
C#3y ago
mae ling

❔ CSharp Socket Stream Stacks

The stream buffer stacks data, instead of receiving, processing, repeating loop.

                while (IsAlive && Connection.Connected)
                {
                    string data = "";
                    byte[] bytes = new byte[4096];

                    BytesReceived += Connection.Receive(bytes);
                    data = Encoding.ASCII.GetString(bytes);


I am trying to receive json data, but the data gets stacked into a single buffer. (Shown in the image posted)
Is it because the receive size needs to be satisfied fully before unblocking the Receive call?
image.png
Was this page helpful?