unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPServer, StdCtrls, IdTCPConnection,
IdTCPClient;
type
TForm1 =
class(TForm)
Memo1: TMemo;
Edit1: TEdit;
Button1: TButton;
Server: TIdTCPServer;
Button2: TButton;
Client: TIdTCPClient;
procedure ServerExecute(AThread: TIdPeerThread);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
Server.Active:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with Server
do
DefaultPort:=strtoint(edit1.text);
Server.Active:=true;
begin
Client.Host:=('
'+Edit1.text);
Client.Connect();
Client.WriteLn(Edit1.Text);
end;
end;
procedure TForm1.ServerExecute(AThread: TIdPeerThread);
var
ms:
string;
begin
ms:=athread.Connection.ReadLn('
',10);
Memo1.Lines.Add(ms);
end;
end.