views:

441

answers:

1

Hi everyone,

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!

A: 

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.

Barry Kelly
That's true, but that isn't related to the main problem itself. The problem is that I receive many empty packets in my server application, even though I call beginsend only once. Still thanks for your help!
See my comment on your question for my response.
Barry Kelly