Re: Data sent - flushing remainder
- From: "Daniel" <DanielV@xxxxxxxxxxxxxxxx>
- Date: Sun, 26 Feb 2006 16:44:52 -0000
This is my issue, what if the tilda character does appear in the text?
I will never know the exact length of the data coming through so i thought i
could append the data size to be expected to the first 4 bytes. Which is
what your saying i presume?
If i do this i will read the first 4 to get size, then read that amount of
data and now do something with the data received. BUT i will still continue
to receive that excess data as my socket remains open listening.
So...if i send over 4096 bytes of data but only 3060 bytes of that data are
what i need and my client receives in buffer sizes of 1024, my client will
receive in total 4096 bytes as it should.
Are you saying i should receive until i get the full amount of data being
sent across (the 4096) and then read from that the first 4 bytes and say
only use the amount specified (3060) . This would work but how does it know
when to stop at say 4096. The next send across may use more data than that?
And as there is no end of data character and i do not close the socket i
have no way of telling it when to stop. In this case should i set a maximum
buffer receive size of say 4096 bytes or however big i need and then always
read until it receives in total that amount and ensure my server pads out
its buffer to always send that amount also then use the first 4 bytes to get
the real data size?
Surely that is very wasteful?
Alternatively if i am sending the data in 1024 byte chunks, i could receive
the first chunk, read the first 4 bytes and get the value 3060. Then read
that many bytes in and tell it to only restart storing the data being sent
once the first byte does not equal 0 as the next set of bytes that contain
size clearly will not be 0 and we can presume it is the size of the next
chunk.
That must be the best option? Any issues with that?
"Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx> wrote in message
news:e41jmcqOGHA.2128@xxxxxxxxxxxxxxxxxxxxxxx
First : are you sure that you have no tilda character in the text ?
Second: If you don't want to read extra data you have to set length and
read that number of bytes ( in this case you don't need end delimiter ).
After that issue next read when you need that, that will allow you to have
socket always opened
Arkady
"Daniel" <DanielV@xxxxxxxxxxxxxxxx> wrote in message
news:ekQ%23HWkOGHA.2992@xxxxxxxxxxxxxxxxxxxxxxx
On my prog i this happens.
Client sends request for data
Server receives request and responds by sending reply object which is
serialised and appends end of data character '~'
Client receives serialised data and reads until end of character read
then breaks.
However i keep my socket open and after that read put it back into a
waitingfordata asynchornous call. At this point it reads in some 1036
more bytes which were left over from the previous read and appends this
to my cumulative memory stream
I do not want that surplus to be read into my memory stream so how can i
stop that as i know after my endofstream token that i do not want the
rest of what is on my socket.
But if i flush the data i could lose some of my next request.
So 2 solutions?
1) append a start of data character as well then read both.
2) close the socket after the end of charatcer read and start a new
connection when i next need data, i was advised to use persistent sockets
tho but i dont know why?
Any ideas?
.
- Follow-Ups:
- Re: Data sent - flushing remainder
- From: Scherbina Vladimir
- Re: Data sent - flushing remainder
- References:
- Data sent - flushing remainder
- From: Daniel
- Re: Data sent - flushing remainder
- From: Arkady Frenkel
- Data sent - flushing remainder
- Prev by Date: How can i force sending ACK after receiving FIN from server while close session?
- Next by Date: Re: Data sent - flushing remainder
- Previous by thread: Re: Data sent - flushing remainder
- Next by thread: Re: Data sent - flushing remainder
- Index(es):
Relevant Pages
|
Loading