Unit1.pas
上传用户:tsdongzun
上传日期:2021-04-22
资源大小:174k
文件大小:1k
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, ScktComp;
- type
- TForm1 = class(TForm)
- ListBox1: TListBox;
- Panel1: TPanel;
- Button1: TButton;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- ServerSocket1: TServerSocket;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- ServerSocket1:=TServerSocket.Create(self);
- ServerSocket1.Active:=true;
- end;
- procedure TForm1.FormDestroy(Sender: TObject);
- begin
- ServerSocket1.Free;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- var
- i:integer;
- begin
- ListBox1.Items.Clear;
- for i:=1 to 10000 do
- begin
- ServerSocket1.Close;
- ServerSocket1.Port:=i;
- try
- ServerSocket1.Open;
- except
- ListBox1.Items.Add(IntToStr(i)+'端口被打开');
- end;
- end;
- end;
- end.