I am messing around with the Indy 10 supplied with Delphi 2009 and am having trouble with getting all the data from the IOHandler when OnExecute fires...
pro
procedure TFormMain.IdTCPServerExecute(AContext: TIdContext);
var
RxBufStr: UTF8String;
RxBufSize: Integer;
begin
if AContext.Connection.IOHandler.Readable then
begin
AContext.Connection.IOHandler.ReadBytes(TBytes(RxBufStr),-1, False);
end;
end;
You should not be using Readable() like that. Try the following instead:
procedure TFormMain.IdTCPServerExecute(AContext: TIdContext);
var
RxBuf: TIdBytes;
begin
RxBuf := nil;
with AContext.Connection.IOHandler do
begin
CheckForDataOnSource(10);
if not InputBufferIsEmpty then
begin
InputBuffer.ExtractToBytes(RxBuf);
// process RxBuf as needed...
end;
end;
end;
Alternatively:
procedure TFormMain.IdTCPServerExecute(AContext: TIdContext);
var
RxBufStr: String; // not UTF8String
begin
with AContext.Connection.IOHandler do
begin
CheckForDataOnSource(10);
if not InputBufferIsEmpty then
begin
RxBufStr := InputBuffer.Extract(-1, enUtf8);
// Alternatively to above, you can set the
// InputBuffer.Encoding property to enUtf8
// beforehand, and then call TIdBuffer.Extract()
// without any parameters.
//
// Or, set the IOHandler.DefStringEncoding
// property to enUtf8 beforehand, and then
// call TIdIOHandler.InputBufferAsString()
// process RxBufStr as needed...
end;
end;
end;
As for TIdSchedulerOfFiber - the SuperCore package is effectively dead at this time. It has not been worked on in a very long time, and is not up-to-date with the latest Indy 10 architecture. We may try to resurrect it at a later date, but it is not in our plans for the near future.