unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdTCPConnection, IdTCPClient, IdBaseComponent, IdComponent,
IdTCPServer, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
server: TIdTCPServer;
client: TIdTCPClient;
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
Image1: TImage;
Image2: TImage;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure serverExecute(AThread: TIdPeerThread);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
server.Active := true;
memo1.Lines[0] := '
';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
client.Connect();
end;
procedure TForm1.serverExecute(AThread: TIdPeerThread);
Var stream2: TMemorystream;
begin
Stream2 := TMemoryStream.Create;
Stream2.Clear;
Athread.Connection.ReadStream(Stream2, -1, true);
//<-------
Stream2.SaveToFile('
c:\testbild01.bmp');
Stream2.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
Var Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
Stream.LoadFromFile('
c:\bild.bmp');
Stream.Position := 0;
Client.OpenWriteBuffer;
Client.WriteStream(Stream);
// <----
Client.CloseWriteBuffer;
Stream.Free;
end;
end.