C
C#2y ago
boom

❔ 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);
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?
2 Replies
boom
boom2y ago
The error is due to Newtonsoft.Json not being able to split the multiple dictionaries stacked into the buffer. How do i avoid it stacking?
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.