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;
CheckBox9: TCheckBox;
CheckBox10: TCheckBox;
CheckBox11: TCheckBox;
CheckBox12: TCheckBox;
CheckBox13: TCheckBox;
CheckBox14: TCheckBox;
CheckBox15: TCheckBox;
CheckBox16: TCheckBox;
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 ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure CheckBox3Click(Sender: TObject);
procedure CheckBox4Click(Sender: TObject);
procedure CheckBox5Click(Sender: TObject);
procedure CheckBox6Click(Sender: TObject);
procedure CheckBox7Click(Sender: TObject);
procedure CheckBox8Click(Sender: TObject);
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
procedure CheckBox9Click(Sender: TObject);
procedure CheckBox10Click(Sender: TObject);
procedure CheckBox11Click(Sender: TObject);
procedure CheckBox12Click(Sender: TObject);
procedure CheckBox13Click(Sender: TObject);
procedure CheckBox14Click(Sender: TObject);
procedure CheckBox15Click(Sender: TObject);
procedure CheckBox16Click(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;
procedure TIP.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var text:
String;
begin
text := Socket.ReceiveText;
if text[1] = '
1'
then
if text[2] = '
t'
then checkbox9.checked := true
else checkbox9.checked := false;
if text[1] = '
2'
then
if text[2] = '
t'
then checkbox10.checked := true
else checkbox10.checked := false;
if text[1] = '
3'
then
if text[2] = '
t'
then checkbox11.checked := true
else checkbox11.checked := false;
if text[1] = '
4'
then
if text[2] = '
t'
then checkbox12.checked := true
else checkbox12.checked := false;
if text[1] = '
5'
then
if text[2] = '
t'
then checkbox13.checked := true
else checkbox13.checked := false;
if text[1] = '
6'
then
if text[2] = '
t'
then checkbox14.checked := true
else checkbox14.checked := false;
if text[1] = '
7'
then
if text[2] = '
t'
then checkbox15.checked := true
else checkbox15.checked := false;
if text[1] = '
8'
then
if text[2] = '
t'
then checkbox16.checked := true
else checkbox16.checked := false;
end;
procedure TIP.CheckBox1Click(Sender: TObject);
begin
If Checkbox1.checked
then Clientsocket1.socket.sendtext('
1t')
else Clientsocket1.socket.sendtext('
1f');
end;
procedure TIP.CheckBox2Click(Sender: TObject);
begin
If Checkbox2.checked
then Clientsocket1.socket.sendtext('
2t')
else Clientsocket1.socket.sendtext('
2f');
end;
procedure TIP.CheckBox3Click(Sender: TObject);
begin
If Checkbox3.checked
then Clientsocket1.socket.sendtext('
3t')
else Clientsocket1.socket.sendtext('
3f');
end;
procedure TIP.CheckBox4Click(Sender: TObject);
begin
If Checkbox4.checked
then Clientsocket1.socket.sendtext('
4t')
else Clientsocket1.socket.sendtext('
4f');
end;
procedure TIP.CheckBox5Click(Sender: TObject);
begin
If Checkbox5.checked
then Clientsocket1.socket.sendtext('
5t')
else Clientsocket1.socket.sendtext('
5f');
end;
procedure TIP.CheckBox6Click(Sender: TObject);
begin
If Checkbox6.checked
then Clientsocket1.socket.sendtext('
6t')
else Clientsocket1.socket.sendtext('
6f');
end;
procedure TIP.CheckBox7Click(Sender: TObject);
begin
If Checkbox7.checked
then Clientsocket1.socket.sendtext('
7t')
else Clientsocket1.socket.sendtext('
7f');
end;
procedure TIP.CheckBox8Click(Sender: TObject);
begin
If Checkbox8.checked
then Clientsocket1.socket.sendtext('
8t')
else Clientsocket1.socket.sendtext('
8f');
end;
procedure TIP.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
var text:
String;
begin
text := Socket.ReceiveText;
if text[1] = '
9'
then
if text[2] = '
t'
then checkbox1.checked := true
else checkbox1.checked := false;
if text[1] = '
10'
then
if text[2] = '
t'
then checkbox2.checked := true
else checkbox2.checked := false;
if text[1] = '
11'
then
if text[2] = '
t'
then checkbox3.checked := true
else checkbox3.checked := false;
if text[1] = '
12'
then
if text[2] = '
t'
then checkbox4.checked := true
else checkbox4.checked := false;
if text[1] = '
13'
then
if text[2] = '
t'
then checkbox5.checked := true
else checkbox5.checked := false;
if text[1] = '
14'
then
if text[2] = '
t'
then checkbox6.checked := true
else checkbox6.checked := false;
if text[1] = '
15'
then
if text[2] = '
t'
then checkbox7.checked := true
else checkbox7.checked := false;
if text[1] = '
16'
then
if text[2] = '
t'
then checkbox8.checked := true
else checkbox8.checked := false;
end;
procedure TIP.CheckBox9Click(Sender: TObject);
begin
If Checkbox9.checked
then Serversocket1.socket.sendtext('
9t')
else Serversocket1.socket.Connections[0].sendtext('
9f');
end;
procedure TIP.CheckBox10Click(Sender: TObject);
begin
If Checkbox10.checked
then Serversocket1.socket.sendtext('
10t')
else Serversocket1.socket.Connections[0].sendtext('
10f');
end;
procedure TIP.CheckBox11Click(Sender: TObject);
begin
If Checkbox11.checked
then Serversocket1.socket.sendtext('
11t')
else Serversocket1.socket.Connections[0].sendtext('
11f');
end;
procedure TIP.CheckBox12Click(Sender: TObject);
begin
If Checkbox12.checked
then Serversocket1.socket.sendtext('
12t')
else Serversocket1.socket.Connections[0].sendtext('
12f');
end;
procedure TIP.CheckBox13Click(Sender: TObject);
begin
If Checkbox13.checked
then Serversocket1.socket.sendtext('
13t')
else Serversocket1.socket.Connections[0].sendtext('
13f');
end;
procedure TIP.CheckBox14Click(Sender: TObject);
begin
If Checkbox14.checked
then Serversocket1.socket.sendtext('
14t')
else Serversocket1.socket.Connections[0].sendtext('
14f');
end;
procedure TIP.CheckBox15Click(Sender: TObject);
begin
If Checkbox15.checked
then Serversocket1.socket.sendtext('
15t')
else Serversocket1.socket.Connections[0].sendtext('
15f');
end;
procedure TIP.CheckBox16Click(Sender: TObject);
begin
If Checkbox16.checked
then Serversocket1.socket.sendtext('
1t')
else Serversocket1.socket.Connections[0].sendtext('
16f');
end;
end.