unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ScktComp;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ServerSocket1: TServerSocket;
    Edit1: TEdit;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
If ServerSocket1.Active = False Then
begin
ServerSocket1.Active := True ;
Button1.Caption := 'Ãö³¬' ;
end
else begin
ServerSocket1.Active := False ;
Button1.Caption := '³s½u' ;
end
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
ServerSocket1.Socket.Connections[0].SendText(Edit1.Text);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
If ServerSocket1.Active = True then ServerSocket1.Close;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
If ServerSocket1.Active = True then ServerSocket1.Close;
end;

end.
