海林市信息网:Delphi中代码执行问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/05 10:43:26
在Delphi中写了如下代码,执行起来超慢,而且好像检测不完全,为什么?应该怎样改进?
for i:=1 to 255 do
begin
tcpclient1.RemoteHost:=trim(edit1.Text);
tcpclient1.RemoteHost:=tcpclient1.RemoteHost+'.'+inttostr(i);
if tcpclient1.Connect then
listbox2.Items.Add(tcpclient1.RemoteHost);
end;

for i:=1 to 255 do
begin
tcpclient1.RemoteHost:=edit1.text+'.'+inttostr(i);
if tcpclient1.Connect then
begin
tcpclient1.disconnect(关闭连接,具体方法忘了);
listbox2.Items.Add(tcpclient1.RemoteHost);
end;
end;

开200多个连接,你说能快吗,一般的服务器都受不了,要用缓冲.
另外,循环内第一句话纯属浪费.

是不是想做一个代理检测软件啊
连网本来就是很慢的,指定超时时间比较好