Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: How to read data with case insensitive terminator in TIdTCPServer?

www.cryer.info
Managed Newsgroup Archive

Re: How to read data with case insensitive terminator in TIdTCPServer?

Subject:Re: How to read data with case insensitive terminator in TIdTCPServer?
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Mon, 26 Mar 2007 02:45:28

"Bo Berglund" <bo.berglund@telia.com> wrote in message
news:kaoe03liis0r66ncj2ljfoil0qkro7h0n6@4ax.com...

> In my case the terminator is '</msg>. But not always...
>
> How can I deal with messages that end in:
> </msg> or </MSG> or <msg/> or <MSG/> or <msg />????

By not using ReadLn() at all.  You will just have to manually scan
through all incoming data that arrives.  I gave you an example of
exactly that in the "How to set the listen port for the TIdTCPServer?"
discussion in this same newsgroup.

> If the data do not contain the ending sequence when the OnExecute
> is fired, but they arrive in a later packet, what remains of the
original
> data on the second firing of OnExecute if I have done a ReadLn in
> the first (without getting anything)???

ReadLn() removes the returned data from the InputBuffer.  If you do
not buffer it yourself somewhere else, then it is gone forever.  The
example I gave you earlier leaves the data in the InputBuffer until it
is actually ready to be extracted.

On the other hand, since you are using ReadLn() with a timeout, when
it returns an empty string, and the ReadLnTimedOut property is set to
True when ReadLn() exits, then no data has been extracted from the
InputBuffer yet, so it will still exist when you call any of the
reading methods again at a later time.


Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive