I'm having a weird problem with my code, at the moment everything works fine, except the sending part. Whenever I try to send a packet it actually sends many empty packets, and I can't find out why, I've checked with the debugger and the SendPacket function is being called only once. Thanks to everyone!
What I see: you pass an array (loginOutBuffer
) to Socket.BeginSend()
in SendPacket
via OnPacketRecv
, but you clear it immediately after in OnPacketRecv
.
Socket.BeginSend()
doesn't make a copy of the array when you pass it in, so it will send the data in the now-cleared array, resulting in zeros coming out the other end.