Re: Finding start and end of data in a stream
- From: "Daniel" <DanielV@xxxxxxxxxxxxxxxx>
- Date: Fri, 21 Jul 2006 12:59:11 +0100
Hi
Sorry you have misunderstood, i am not talking of data going out of order. i
will explain again and try and be more clear.
Say the server sends data to the client and seands 2 sets of data one after
the other.
The first data sent is 300bytes and the second set of data is 250 bytes.
I already append the length of the data to the first 4 bytes of the data of
each when sent.
So then on the client end it has a receive buffer of 1024 bytes.
So when it receives the data it receives the 300bytes first and then the 250
bytes. But if some processing went on before the second 250 bytes was sent
then the stream may have a gap in it. Can this happen? So that the data
arrives possibly like this:
1024 byte receiver buffer, with first 300 bytes as first data sent. then a
gap of x many bytes of empty data in receive buffer then the final 250bytes.
So you see still in order but with a gap. its that gap that causes me the
problem. In a binary stream how do i tell my client when the second 250
bytes started, and to ignore the gap?
As lxRob said simialr to an end character i could put in a start character
as the length data will tell me when to stop reading that segment anyway.
But what character? How do i know this character will not be in my stream
anywhere as i am serialising an object.
Is that clearer?
"Dave Lowther" <davel@xxxxxxxxx> wrote in message
news:OIbblBLrGHA.4508@xxxxxxxxxxxxxxxxxxxxxxx
"Daniel" <DanielV@xxxxxxxxxxxxxxxx> wrote in message
news:%23eWvI5KrGHA.3816@xxxxxxxxxxxxxxxxxxxxxxx
Hey guys
In a stream is this possible that say you have a byte buffer of 1024
bytes, can this occur if 250bytes of data were sent then soon after
300bytes of data:
Data can not arrive out of order in a TCP stream.
I usually wrap recv() to make a function recv_n_bytes(), with internal
state and buffer in the recv_n_bytes() function.
When you have done the recv_n_bytes() to get the length, then do
recv_n_bytes() to get the data using the length.
HTH
Dave.
.
- Follow-Ups:
- Re: Finding start and end of data in a stream
- From: Dave Lowther
- Re: Finding start and end of data in a stream
- References:
- Finding start and end of data in a stream
- From: Daniel
- Re: Finding start and end of data in a stream
- From: Dave Lowther
- Finding start and end of data in a stream
- Prev by Date: Re: Finding start and end of data in a stream
- Next by Date: Re: Finding start and end of data in a stream
- Previous by thread: Re: Finding start and end of data in a stream
- Next by thread: Re: Finding start and end of data in a stream
- Index(es):
Relevant Pages
|