Ok, habe es nun so gelöst:
Delphi-Quellcode:
if not MyIdTCPClient.IOHandler.InputBufferIsEmpty then
begin
if StreamComplete then
begin
fileStream := TMemoryStream.Create;
TempStream := TMemoryStream.Create;
MyIdTCPClient.IOHandler.InputBuffer.ExtractToStream(TempStream);
TempStream.Seek(0, soFromBeginning);
TempStream.Read(StreamSize, SizeOf(Int64));
fileStream.CopyFrom(TempStream, TempStream.Size - SizeOf(Int64));
if fileStream.Size >= StreamSize then
begin
EventCallbackProcedure(fileStream);
FreeAndNil(TempStream);
FreeAndNil(fileStream);
StreamComplete := True;
end
else
StreamComplete := False;
end
else begin
TempStream.Clear;
MyIdTCPClient.IOHandler.InputBuffer.ExtractToStream(TempStream);
TempStream.Seek(0, soFromBeginning);
fileStream.CopyFrom(TempStream, TempStream.Size);
if fileStream.Size >= StreamSize then
begin
EventCallbackProcedure(fileStream);
FreeAndNil(TempStream);
FreeAndNil(fileStream);
StreamComplete := True;
end;
end;
end;