- Home /
Question by
doczoidberg · Aug 16, 2018 at 04:56 PM ·
tcpclient
TCP IP socket.receive data does not go through
I send data via TCP from a .NET application to Unity but all bytes aren't received. This is the case with a simple .NET wpf application with the same code. Why is there a difference in Unity? Both is based on .NET 4.7?
// Data send from .NET application: Stream stm = tcpclnt.GetStream();
byte[] ba = memoryStream.ToArray();
var buffer = BitConverter.GetBytes(ba.Length);
stm.Write(buffer, 0, buffer.Length);
stm.Write(ba, 0, ba.Length);
// Data receive works in .NET but in Unity not all bytes are received
byte[] lengthb = new byte[32];
int k = s.Receive(lengthb);
int size = BitConverter.ToInt32(lengthb, 0);
byte[] lengthframe = new byte[size];
s.ReceiveBufferSize = size;
int kf = s.Receive(lengthframe);
Comment