Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Oct : Re: Funny error TCPclient
| Subject: | Re: Funny error TCPclient |
| Posted by: | "GannTrader" (a@a.com) |
| Date: | Mon, 16 Oct 2006 00:18:32 |
Hi
Yes that solved the problem.
But i hope you ment
FIndyClient.IOHandler.CheckForDataOnSource(IdTimeoutInfinite);
instead of :)
FIndyClient.CheckForDataOnSource(IdTimeoutInfinite);
becourse that didnt funktion.
/GannTrader
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> skrev i meddelandet
news:45300d30$1@newsgroups.borland.com...
>
> "GannTrader" <a@a.com> wrote in message
> news:453005e7@newsgroups.borland.com...
>
>> if findyclient.Connected then // ***If i skip this line then
>> FIndyClient.IOHandler.InputBuffer.Size i always zero
>
> Indy only reads data from the socket when the InputBuffer does not have
> enough bytes to satisfy a reading operation. Given the code you have
> shown,
> you are not actually reading anything from the socket if you omit the call
> to Connected(), so all pending data from the socket is never placed into
> the
> IOHandler's InputBuffer.
>
> To make your code work without explicitially calling Connected(), you have
> to actually read something from the socket. Since you are processing
> arbitrary strings, you will have to call the CheckForDataOnSource() method
> before then extracting the contents of the InputBuffer as a string. For
> example:
>
> procedure TMyReadThread.Read_Stack;
> begin
> FIndyClient.CheckForDataOnSource(IdTimeoutInfinite);
> message1 := FIndyClient.IOHandler.InputBufferAsString:
> end;
>
> procedure TMyReadThread.Execute;
> begin
> Connekt;
> while (not Terminated) do
> begin
> Read_Stack;
> end;
> end;
>
> On the other hand, if your socket data actually has some structure to it,
> then using the various reading methods of the IOHandler (if you call
> ReadString(), you have to specify a non-zero length) will internally call
> CheckForDataOnSource() to fill the InputBuffer accordingly.
>
>
> Gambit
none