unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ScktComp, StdCtrls, ComCtrls;
type
TIP =
class(TForm)
Label1: TLabel;
Label2: TLabel;
ClientVerbinden: TButton;
ClientTrennen: TButton;
ServerVerbinden: TButton;
ServerTrennen: TButton;
PortClient: TEdit;
Label3: TLabel;
IP: TEdit;
Label4: TLabel;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
ClientSocket1: TClientSocket;
ServerSocket1: TServerSocket;
Timer1: TTimer;
PortServer: TEdit;
Label5: TLabel;
Beenden: TButton;
StatusBar1: TStatusBar;
Label6: TLabel;
procedure ClientVerbindenClick(Sender: TObject);
procedure ServerVerbindenClick(Sender: TObject);
procedure BeendenClick(Sender: TObject);
procedure ClientTrennenClick(Sender: TObject);
procedure ServerTrennenClick(Sender: TObject);
procedure ClientSocket1Disconnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
procedure ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
IP: TIP;
implementation
{$R *.DFM}
procedure TIP.ClientVerbindenClick(Sender: TObject);
begin
clientsocket1.address:=
IP.text;
clientsocket1.port:= strtoint(PortClient.text);
clientsocket1.active:=true;
end;
procedure TIP.ServerVerbindenClick(Sender: TObject);
begin
serversocket1.port:= strtoint(PortServer.text);
serversocket1.active:=true;
end;
procedure TIP.BeendenClick(Sender: TObject);
begin
close;
end;
procedure TIP.ClientTrennenClick(Sender: TObject);
begin
clientsocket1.active:=false;
end;
procedure TIP.ServerTrennenClick(Sender: TObject);
begin
serversocket1.active:=false;
end;
procedure TIP.ClientSocket1Disconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
statusbar1.simpletext:='
Verbindung wurde getrennt';
end;
procedure TIP.ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
statusbar1.simpletext:='
Error. Verbindung wird getrennt!';
//Bei Fehler wird Verbindung getrennt
clientsocket1.Active:=false;
end;
procedure TIP.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
begin
statusbar1.simpletext:='
Verbunden mit IP ' +
IP.text+ '
und Port ' + PortClient.text;
end;
end.