Here's how the receiver will receive the stream.
Ms := TMemoryStream.Create;
try
Ms.Position := 0;
Connection.IOHandler.LargeStream := True;
Connection.IOHandler.ReadStream(Ms, -1,false);
finally
Ms.Free;
end;
If the receiver wants to cancel it
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
try Ms.Free; except end;
end;
This doesn't work well, the application sometimes closes.
Also for the sender...
Ms := TMemoryStream.Create;
try
Ms.Position := 0;
Connection.IOHandler.LargeStream := True;
Connection.IOHandler.Write(Ms, 0, True);
finally
Ms.Free;
end;
The same with the sender in canceling the stream.
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
try Ms.Free; except end;
end;
What is the proper way to cancel the stream that is being send or receive ?