Board index » delphi » Readln doesn't time out...

Readln doesn't time out...

Hi,

I'm trying to create my own protocol using TidTCPServer & TidTCPClient.

I use SendCmd then call readln from the client. But if the server doesn't
respond, readln doesn't time out as well.

Is this a bug, or am I doing something wrong?

Thanks.

 

Re:Readln doesn't time out...


Quote
"Hasan Ceylan" <hcey...@biletix.com> wrote in message

news:97ama9$jvs1@bornews.inprise.com...

Quote
> I use SendCmd then call readln from the client. But if the server doesn't
> respond, readln doesn't time out as well.

TIdTCPConnection.ReadLn
Reads a line from the Indy buffer.

function ReadLn(const ATerminator: string; const ATimeout: integer): string;
virtual;

Parameters

const ATerminator: string = ''
End-of-line termination character or characters.

const ATimeout: integer = IdTimeoutInfinite
Time-out in milliseconds. Default value IdTimeoutInfinite.

Returns

String - Line read from the buffer.

Description

ReadLn is a function that returns a string containing a single line from the
buffer maintained by TIdTCPConnection.

The optional ATerminator parameter indicates the end-of-line symbol for the
particular protocol. If data is expected, and you do not need a custom
end-of-line symbol, you can use the default ATerminator value (#0).
ATerminator values include:

ATerminator Values

#0 - Default Line Feed (#10)
LF - Line Feed (#10)
CR - Carriage Return (#13)
EOL - End-of-line (Carriage Return + Line Feed)

If there is no terminator (ATerminator) in the buffer, ReadLn will read more
bytes from the TCP stack through the ReadFromStack method.

Use a custom time-out (ATimeout) value to change the number of milliseconds
to wait for a response from the peer connection before a time-out occurs.
The default value for ATimeout is IdTimeoutInfinite. See IdGlobal.pas for
more information on constant timeout values.

ReadLn will return an empty string ('') if the peer connection is
prematurely closed or a time-out occurs. When a timeout condition occurs in
ReadLn, the ReadLnTimedOut property is set to True.

Re:Readln doesn't time out...


hcey...@biletix.com (Hasan Ceylan) wrote in <97ama9$jvs1
@bornews.inprise.com>:

Quote
>I'm trying to create my own protocol using TidTCPServer & TidTCPClient.

>I use SendCmd then call readln from the client. But if the server doesn't
>respond, readln doesn't time out as well.

>Is this a bug, or am I doing something wrong?

Its something in your app. Trace your server.

--
Chad Z. Hower (Kudzu) - Church Hill, TN - Team Indy
      "Programming is an art form that fights back"
Forget the Y2K problem, Lets fix the W2K problem.
http://www.pbe.com/Kudzu/ - Free Delphi/CBuilder components and articles

Re:Readln doesn't time out...


"Kudzu - Team Indy" <chad...@pbe.com> wrote in message
news:9053685B6chadngpbecom@207.105.83.62...

Quote
> hcey...@biletix.com (Hasan Ceylan) wrote in <97ama9$jvs1
> @bornews.inprise.com>:
> >I'm trying to create my own protocol using TidTCPServer & TidTCPClient.

> >I use SendCmd then call readln from the client. But if the server doesn't
> >respond, readln doesn't time out as well.

> >Is this a bug, or am I doing something wrong?

> Its something in your app. Trace your server.

Actually I was trying the case client and server loses synchronization.

So got client send a cmd to the server. server doesn't responds. And client
waits indefinitely with the line

readln(EOL, 3000).

Does time out cover broken connections and communication error cases or does
it also covers cases like technically everything is OK but communication is
lost because of client waits for an answer but server doesn't think it's
suppossed to send something to the client.

sorry for bad english, hope this is understandable ;)

Hasan

Quote

> --
> Chad Z. Hower (Kudzu) - Church Hill, TN - Team Indy
>       "Programming is an art form that fights back"
> Forget the Y2K problem, Lets fix the W2K problem.
> http://www.pbe.com/Kudzu/ - Free Delphi/CBuilder components and articles

Re:Readln doesn't time out...


ceylan...@hotmail.com (Alter) wrote in <3a9b5717_2@dnews>:

Quote
>readln(EOL, 3000).

This will time out if there has been no activity for 3 seconds. Not 3 seconds
from when you call it.

Quote
>Does time out cover broken connections and communication error cases or does
>it also covers cases like technically everything is OK but communication is
>lost because of client waits for an answer but server doesn't think it's

Yes. If the connection is broken an exception will be raised.

--
Chad Z. Hower (Kudzu) - Church Hill, TN - Team Indy
      "Programming is an art form that fights back"
Forget the Y2K problem, Lets fix the W2K problem.
http://www.pbe.com/Kudzu/ - Free Delphi/CBuilder components and articles

Other Threads