//Formumuza 3 Edit, 1 openDialod, 1 saveDialog, 1 Button, 1 NMStrm, 1 NMStrmServ, 1 İmage Ekleyin ve asagıdakı kodları yazın
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.text:='127.0.0.1';
edit2.text:='6711';
edit3.text:='Adınızı Giriniz';
NMstrm1.timeout:=90000;
NMStrmServ1.Timeout:=90000;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
NMStrm1.host:=edit1.text;
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
NMstrm1.port:=strtoint(edit2.text);
nmstrmserv1.port:=strtoint(edit2.text);
end;
procedure TForm1.Edit3Change(Sender: TObject);
begin
nmstrm1.fromname:=edit3.text;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Fstrm: TFileStream;
begin
if opendialog1.execute then
begin
FStrm:=TFilestream.create(Opendialog1.Filename, fmopenread);
try
NMStrm1.postit(Fstrm);
finally
FStrm.free;
end;
end;
end;
procedure TForm1.NMStrm1PacketSent(Sender: TObject);
begin
Caption:=inttostr(nmstrm1.bytessent)+'/'+ inttostr(nmstrm1.bytestotal);
end;
procedure TForm1.NMStrm1MessageSent(Sender: TObject);
begin
Caption:='Dosya Gönderildi';
end;
procedure TForm1.NMStrmServ1MSG(Sender: TComponent; const sFrom: String;
strm: TStream);
var
fstrm:tfilestream;
begin
Caption:=sfrom+'dan'+inttostr(strm.size)+'boyutunda dosya geldi';
if savedialog1.execute then
begin
if fileexists(savedialog1.filename) then
deletefile(savedialog1.filename);
fstrm:=tfilestream.create(savedialog1.filename, fmcreate);
try
fstrm.copyfrom(strm, strm.size);
finally
end;
if lowercase(Extractfileext(savedialog1.filename))='.bmp' then
image1.picture.loadfromfile(savedialog1.filename);
end;
end;
end.