Reading bytes from a socket

  • Thread starter Thread starter Diego F.
  • Start date Start date
D

Diego F.

Hello. I have a problem while reading bytes from a socket.

According to my test, it seems that the buffer maximum size is 8192 bytes.
Then, I use a byte array with that size to read from the buffer. If the send
data size is 8192 or less, it works ok.

But, if I send more that 8192, let's say 10000 bytes, the first time I read
from the buffer I get 8192, and the second, instead of 1808 bytes, it reads
8192 again!!!

Isn't the buffer emptied after the reading?
 
try adding

Array.Clear(buffer, 0, buffer.length)

at the end of your receive method. this way the buffer will be cleared of
all information and you wont have any remains from the previous read....see
if that helps
 
Back
Top