|Subject:||Re: TIdTCPConnection Question.|
|Posted by:||Remy Lebeau (TeamB) (email@example.com)|
|Date:||Mon, 18 Apr 2005|
"jim" <gy…@vivodinet.gr> wrote in message
> Is there a way to determine if there is data ready in the
> connection without extracting them from the InputBuffer?
What are you really asking for? Do you want to check the underlying socket
itself, or just Indy's InputBuffer? The two are very different. When Indy
reads anything, it comes from the InputBuffer. When the InputBuffer does
not have enough bytes to satisfy the read, it reads more data from the
socket and places it into the InputBuffer.
> How can i solve this problem?
What problem exactly? What exactly are you trying to accomplish?
> I cannot use ReadBuffer in the first place because
> there is no certainty of what the data will be.
Are you saying that you do not know ahead of time how much data to expect
before you read it? If so, then why do you have that scenerio to begin
with? That is not a good way to manage socket data.
> i can maybe want to read an integer or a string or
> other data.
Integers have a fixed size, so you always know how many bytes to read. A
string can be length-prefixed to accomplish the same effect. So again, I
ask, what EXACTLY are you having a problem with? Please provide more
details. What does your code look like? What does your data look like?
> if i call ReadFromStack and then call ReadBuffer
> why won't readbuffer try to check the inputbuffer
> before calling ReadFromStack?
It already does. Where did you get the idea that it doesn't? If the
InputBuffer does not have the requested number of bytes, ReadBuffer()
continuously calls ReadFromStack() until the InputBuffer does have enough
TIdTCPConnection Question. posted by jim on Mon, 18 Apr 2005