Internet Direct (Indy)
Home
PreviousUpNext
TIdIOHandler.ReadLn Method (string, Integer, Integer)

Reads a line from the Indy buffer.

Pascal
function ReadLn(
    ATerminator: string; 
    ATimeout: Integer = IdTimeoutDefault; 
    AMaxLineLength: Integer = -1
): string; virtual; overload;
Parameters 
Description 
ATerminator 
End-of-line termination character or characters.
 
ATimeout 
Time-out in milliseconds.
 
AMaxLineLength 
Maximum length allowed for the line read from the IOHandler. 

String - Line read from the buffer.

ReadLn is a String function that returns a a single line from the input buffer maintained for the IOHandler. 

ATerminator is an optional parameter that indicates the end-of-line symbol for the client or protocol. When ATerminator is not specified or contains an empty string, LF is used as the default terminator. If data is expected and you do not need a custom end-of-line symbol, you can use the default ATerminator value or one of the following: 

 

Char 
Description 
LF 
Line Feed (Decimal 10) 
CR 
Carriage Return (Decimal 13) 
EOL 
End-of-line (Carriage Return + Line Feed) 

 

ATimeout allows the client to use a custom timeout 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 IdTimeoutDefault

AMaxLineLength is used to indictate that ReadLn cannot accept a string with a length in excess of the parameter value. The default value for AMaxLineLength is -1, and indicates that the value in the MaxLineLength property should be used in ReadLn. 

ReadLn retrieves data from InputBuffer until the symbol in ATerminator is located, AMaxLineLength is exceeded, the socket connection is closed, or a timeout occurs. If there is not enough data to satisfy the request, ReadLn calls CheckForDisconnect to update the IOHandler status and reads data from the data source for the IOHandler connection. 

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

ReadLn can raise an EIdReadLnMaxLineLengthExceeded exception when the position of ATerminator in InputBuffer is greater than the value in AMaxLineLength, and MaxLineAction contains maException. 

When MaxLineAction is not maException, ReadLnSplit is set to True and the string is extracted from InputBuffer

All ATerminator characters in the return value for ReadLn (including CR characters) are removed prior to exiting from the method.

Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.