Unit1.pas
资源名称:scan.rar [点击查看]
上传用户:nieyueshi
上传日期:2022-07-24
资源大小:5k
文件大小:1k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ScktComp, StdCtrls;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- ListBox1: TListBox;
- ServerSocket1: TServerSocket;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- I : integer;
- begin
- ListBox1.Items.Clear;
- for I := 0 to 1024 do
- begin
- ServerSocket1.Close; //关闭SOCKET
- ServerSocket1.Port := I; //设置本地端口
- application.ProcessMessages;//防止程序假死
- form1.caption:=inttostr(i);
- try
- ServerSocket1.Open; //对设置的端口进行监听
- except //如果监听出错,也就是表示端口已经开放了
- ListBox1.Items.Add(IntToStr(I) + '端口被打开');
- end;
- end;
- end;
- end.