I messed around with Indy 10 shipped with Delphi 2009, and I'm having trouble getting all the data from IOHandler when OnExecute fires ...
procedure TFormMain.IdTCPServerExecute(AContext: TIdContext); var RxBufStr: UTF8String; RxBufSize: Integer; begin if AContext.Connection.IOHandler.Readable then begin RxBufSize := AContext.Connection.IOHandler.InputBuffer.Size; if RxBufSize > 0 then begin SetLength(RxBufStr, RxBufSize); AContext.Connection.IOHandler.ReadBytes(TBytes(RxBufStr), RxBufSize, False); end; end; end;
AContext.Connection.IOHandler.InputBuffer.Size does not seem reliable and often returns 0, but the next time OnExecute starts, it will pick the correct number of bytes, but it's too late.
Essentially, I want to be able to just grab all the data, fill it in a UTF8String (not a Unicode string), and then parse a special marker. Therefore, I have no headers, and the messages are of variable length. It seems the Indy 10 IOHandlers are not configured for this, or I'm just using it incorrectly.
It would be nice to do something like transferring a buffer of a certain size, fill it as much as possible, and return the number of bytes actually filled, and then continue if there are more.
As an aside, what is the status of TIdSchedulerOfFiber, it looks very interesting, does it work? Does anyone use it? I noticed that this is not a standard installation of Delphi 2009.
Update: I found Msg: = AContext.Connection.IOHandler.ReadLn (# 0, enUTF8); which works, but I still would like to know the answer to the above question, because it is based on IO blocking? This is even more keen on this TIdSchedulerOfFiber.
delphi delphi-2009 indy
Bruce
source share