Is there a limit in the length of the string sent and read with the Indy methods WriteLn
and ReadLn
?
CodePudding user response:
TIdIOHandler.WriteLn()
is limited only by available memory. However, do note that it appends an EOL
(#13#10
) to the end of the input string, producing a new string which is a copy of the original, and then it converts that copy to a TIdBytes
for sending. So more memory will be used than just what you pass in. I'm sure this can be optimized better in the future.
TIdIOHandler.ReadLn()
has an optional AMaxLineLength
parameter that is set to -1
by default. If it is set to < 0
, the TIdIOHandler.MaxLineLength
property will be used instead, which is set to 16384
bytes by default. You can set (A)MaxLineLength
higher if needed, or you can even set it to 0
to disable the limit completely. If (A)MaxLineLength
is set to > 0
and incoming data exceeds that limit, the subsequent behavior depends on the TIdIOHandler.MaxLineAction
property:
maException
(the default): anEIdReadLnMaxLineLengthExceeded
is raised, and the received bytes will remain in theTIdIOHandler.InputBuffer
for subsequent reads.maSplit
: exactly(A)MaxLineLength
number of bytes will be extracted from theTIdIOHandler.InputBuffer
and returned as aString
, and theTIdIOHander.ReadLnSplit
property will be set toTrue
. The leftover bytes will remain in theTIdIOHandler.InputBuffer
for subsequent reads.