S
starxu
Unregistered / Unconfirmed
GUEST, unregistred user!
我想写一个测试端口状态的程序
procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
for i:=1 to 65535 do
try
Clientsocket1.Address := '192.168.0.5';//本机ip
Clientsocket1.Port := i;
Clientsocket1.Active := true;
listbox1.Items.Add('success port : '+inttostr(Clientsocket1.Port));
except
on E:ESocketError do
listbox1.Items.Add('error port : '+inttostr(Clientsocket1.Port));
end;
end;
为什么异常不是引发listbox1.Items.Add('error port : '+inttostr(Clientsocket1.Port));而是调用系统异常处理!
procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
for i:=1 to 65535 do
try
Clientsocket1.Address := '192.168.0.5';//本机ip
Clientsocket1.Port := i;
Clientsocket1.Active := true;
listbox1.Items.Add('success port : '+inttostr(Clientsocket1.Port));
except
on E:ESocketError do
listbox1.Items.Add('error port : '+inttostr(Clientsocket1.Port));
end;
end;
为什么异常不是引发listbox1.Items.Add('error port : '+inttostr(Clientsocket1.Port));而是调用系统异常处理!