unit SC1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
TForm1 = class(TForm)
Bconnect: TButton;
EIp: TEdit;
EPort: TEdit;
BDisconnect: TButton;
procedure FormCreate(Sender: TObject);
procedure BconnectClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure BDisconnectClick(Sender: TObject);
procedure ClientSocketConnect(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
ClientSocket : TClientSocket;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ClientSocket := TClientSocket.Create(nil);
ClientSocket.OnConnect := ClientSocketConnect;
end;
procedure TForm1.BconnectClick(Sender: TObject);
begin
ClientSocket.Host := EIp.Text;
ClientSocket.Port := StrToInt(EPort.Text);
ClientSocket.Open;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ClientSocket.Destroy;
ClientSocket := nil;
end;
procedure TForm1.BDisconnectClick(Sender: TObject);
begin
ClientSocket.Close;
end;
procedure TForm1.ClientSocketConnect(Sender: TObject);
begin
BConnect.Enabled := False;
BDisconnect.Enabled := True;
end;
end.