network receive buffer

  • Thread starter Thread starter Dirk Reske
  • Start date Start date
D

Dirk Reske

Hello,

does somebody know a good way to code a receivebuffer for a network
connection?
I receive the bytes asynchronous from a socket!
now I want to read all the bytes until a newLine is received.

I think of writing I parser method, which is allways called after data
was received.This method looks for a newline in the buffer.
where to store the received bytes? and how to look for the newline?

I don't use the streamreader, because after the newline a specific
amount of binary data is transmitted.


(excuse my english <- I'm from germany)
 
do it in a seperate thread, always the best way to receive data. When you've
received what you need you just plop it into a thread safe list for somebody
else to handle (or similar).
 
Hi,

If you can modify the protocol you can send first the length and later the
data itself.
If you cannot modify it then there is nothing much you can do, what kind of
data you are receiving?

you could reserve a predetermined buffer size and check when it fills before
receiving the newline, then you could either create a new buffer and stored
the current one, or just redim it.
It all depends of your particular escenario and how the data is intended to
be used.
You could even create a temp file while the data is being read.

cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top