客户端:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, IdAntiFreezeBase, IdAntiFreeze,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
ListBox1: TListBox;
StatusBar1: TStatusBar;
Button1: TButton;
Button2: TButton;
Button3: TButton;
IdTCPClient1: TIdTCPClient;
IdAntiFreeze1: TIdAntiFreeze;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// 连接管理机
procedure TForm1.Button1Click(Sender: TObject);
begin
IdTCPClient1.Host := Edit1.Text;
IdTCPClient1.Port := StrtoInt(Edit2.Text);
ListBox1.Items.Add('正在连接 ' + Edit1.Text + '...');
with IdTCPClient1 do
begin
try
Connect(500);
try
ListBox1.Items.Add(ReadLn());
button1.Enabled := false;
button2.Enabled := true;
button3.Enabled := true;
except
listbox1.Items.Add('