Socket returns no data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have run into a problem which may be a bug in the socket class of .net. My
application is a server that receives heavy volumes of data via multiple
connections using asynchronous socket operations.

After receiving flawlessly for several minutes at heavy volumes (400-800
messages per second) one of the sockets will begin returning a zero-filled
buffer. The data is being generated by a test generator, so I can stop the
data flow and send packets one at a time.

In the data arrival event, the value returned by the EndReceive call is the
correct length of the xpected amount of data ( 56 bytes), but the byte array
it should have put the data in is still filled with zeros (nulls). I used a
LAN sniffer on the same machine to verify that the packets are not being sent
by the data generator filled with nulls. Sometimes it does this only once,
other times it will not revert by itself to proper operation.

Has anyone experienced this? The MS knowledge base has nothing in relation
to this problem. I am almost ready to report this to MS.

Thanks in advance.
 
When using async, normally these issues can be traced back to small coding
issue that will make perfect sense after you find it :-) These can be
common in async and are very easy to do and debug. Off the top, I would
guess the buffer is getting cleared by a prior completion call or the like.
Only way to tell is to review the code. Could you supply a small but
complete sample that will show this issue (i.e. cut your code to down to
bare min. which still will duplicate the issue.) TIA!
 
I am experiencing an almost identical problem.

I don't want to hijack your request, though, so I'll just listen quietly. :)

Would appreciate any insight.

Thanks
 
William,

You're a genius! As you said, once you pointed me in the right direction,
the cause made perfect sense. I found I had an independent processing thread
for the incoming data initiating another read on the socket, which, if timed
right, could re-initialize the receive buffer after the data was received,
but before the data arrival event was triggered by the BeginReceive thread.

Thank you so much for you insight. You made my day!
 
Great! Glad you found it. Was not looking forward to that debug session
(or maybe I was??) Anyway, that makes sense. Cheers!
 
Back
Top