C
C#2y ago
Dipi

✅ Async receive receiving extra bytes

Hello I am building a client to a game when I am communicating with the server it seems that no matter what when the server sending X bytes the client receive x+10 bytes , I know there is some bytes for size,keep alive etc , but I am not sure that is the case
6 Replies
phaseshift
phaseshift2y ago
$details
MODiX
MODiX2y ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
Dipi
DipiOP2y ago
It’s super simple code Creating a buffer passing it to the Socket.RecevieAsync and sending a message form the server and when the the receive async return value is +10 form the actual size sent. for example I am sending 2 bytes the client receive 12
Anchy
Anchy2y ago
share some code
Dipi
DipiOP2y ago
public async Task ReadIncomingPackets(Socket client) {
try {
while (client.Connected) {
byte[] buffer = new byte[4096];
var segment = new ArraySegment<byte>(buffer);
var read = await client.ReceiveAsync(segment,SocketFlags.None);
Debug.Log(read);
}
}
catch (System.Exception e) {
Debug.Log(e);
throw;
}

}
public async Task ReadIncomingPackets(Socket client) {
try {
while (client.Connected) {
byte[] buffer = new byte[4096];
var segment = new ArraySegment<byte>(buffer);
var read = await client.ReceiveAsync(segment,SocketFlags.None);
Debug.Log(read);
}
}
catch (System.Exception e) {
Debug.Log(e);
throw;
}

}
its seems to be fixed god know how....
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server