unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Sockets;
type
TForm2 =
class(TForm)
Button1: TButton;
TcpServer1: TTcpServer;
Memo1: TMemo;
Edit1: TEdit;
Button2: TButton;
Panel1: TPanel;
Panel2: TPanel;
Edit2: TEdit;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure TcpServer1Accept(Sender: TObject; ClientSocket: TCustomIpClient);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
uses unit1;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
Tcpserver1.close;
form2.Close;
form1.Visible:=true;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
Tcpserver1.LocalHost:=edit1.Text;
Tcpserver1.Open;
end;
procedure TForm2.Button3Click(Sender: TObject);
var line2:
string;
begin
line2:=edit2.Text;
Tcpserver1.Sendln(line2);
memo1.Lines.Add('
Host# '+line2);
end;
procedure TForm2.TcpServer1Accept(Sender: TObject;
ClientSocket: TCustomIpClient);
var line:
string;
begin
line:='
';
while ClientSocket.Connected
do
begin
line:=ClientSocket.Receiveln();
memo1.Lines.Add('
Client# '+line);
end;
end;
end.