unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  Borland.Vcl.StdCtrls, System.ComponentModel;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    IdTCPClient1: TIdTCPClient;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.nfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
try
idTCPClient1.Host:=Edit1.Text;
idTCPClient1.Port:=StrToInt(Edit2.Text);
IdTCPClient1.Connect;
Memo1.Lines.Add('- Ustanowiono połączenie z '+idTCPClient1.Host);
except on E:Exception do
  Memo1.Lines.Add('!!! '+e.Message);
end;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if idTCPClient1.Connected then
begin
  IdTCPClient1.Disconnect;
  Memo1.Lines.Add('- Rozlaczono z '+idTCPClient1.Host);
end;

end;

end.
