N
netbug
Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序是监测谁来访问我,并显示端口及主机:
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
for i:=1 to 2000 do
begin
serversocket1.Port:=i;
serversocket1.Active:=true;
if serversocket1.Socket.Connected then
begin
statusbar1.SimpleText:='connect';
edit1.Text:=inttostr(i);
edit2.Text:=serversocket1.Socket.RemoteHost;
exit;
end else serversocket1.Active:=false;
end;
end;
编译能通过,但运行时出现:
project net.exe raised exception with message 'windows socket
error: (10057),on API' getpeername.
并指向 edit2.Text:=serversocket1.Socket.RemoteHost这句,
我把这句删掉,运行没出错,但端口数老是1,请问:
我的程序错在哪?如何改正?谢谢。
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
for i:=1 to 2000 do
begin
serversocket1.Port:=i;
serversocket1.Active:=true;
if serversocket1.Socket.Connected then
begin
statusbar1.SimpleText:='connect';
edit1.Text:=inttostr(i);
edit2.Text:=serversocket1.Socket.RemoteHost;
exit;
end else serversocket1.Active:=false;
end;
end;
编译能通过,但运行时出现:
project net.exe raised exception with message 'windows socket
error: (10057),on API' getpeername.
并指向 edit2.Text:=serversocket1.Socket.RemoteHost这句,
我把这句删掉,运行没出错,但端口数老是1,请问:
我的程序错在哪?如何改正?谢谢。