0

I have been having a heck of a time getting Udp sockets working correctly on Windows Phone 7 (Mango). First I had this problem udp async receive and now that I figured it out, I am seeing a weird behavior where the end of the data I send over the socket is all zero.

At first, I thought there was a weird size cap. All my packets were user 1380 bytes. I was seeing that for some reason, after ~byte 1220 it was all zeros, but according to the socket, I was still receiving all ~1380 bytes. I matched up the sizes with my server application, and I was receiving the correct number of byte. So I printed the bytes out on both sides of the connection and saw this issue with much of the last 200 bytes or so being zero.

So I reduced the size of my packet data to ~1200 bytes, and I was still seeing the issue. I even reduced it to 1000 bytes and still!

Any ideas?

Update - I have done some testing, and it seems that the last 144 bytes are FUBAR. Sometimes they are zero, sometimes they are garbage. Think this is a bug?

Community
  • 1
  • 1
Nick Banks
  • 4,298
  • 5
  • 39
  • 65

2 Answers2

0

You need to check how many bytes were transferred in the async operation. Check SocketAsyncEventArgs.BytesTransferred to see how many bytes in the buffer are actually valid.

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
0

Sorry, I had a bug in my code where I was using an array over, overwriting my own data.

Nick Banks
  • 4,298
  • 5
  • 39
  • 65