unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ScktComp;
type
TForm1 =
class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Panel1: TPanel;
ServerSocket1: TServerSocket;
ClientSocket1: TClientSocket;
Memo1: TMemo;
Memo2: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ServerClientRead(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
text1, text2, da1, da2:
string;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Clear;
Memo2.Clear;
ServerSocket1.Open;
ServerSocket1.Active := true;
Clientsocket1.Open;
Clientsocket1.Active := true;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
text1 := Edit1.Text;
Serversocket1.Socket.SendText(text1);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
text2 := Edit2.Text;
Clientsocket1.Socket.Sendtext(text2);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Clientsocket1.Free;
Serversocket1.Free;
end;
procedure TForm1.ServerClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
da1 := Socket.ReceiveText;
memo1.lines.add(da1);
end;
end.