Вот накидал пример с потоками, работает довольно шустро...
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Winsock, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a : array[0 .. 255] of Byte;
implementation
{$R *.dfm}
procedure RunThread(p : Pointer);
const
mask = '213.189.243.';
port = 80;
var
S:TSocket;
A:TSockAddr;
IP : String;
Buf : String;
begin
try
Buf := 'Port is opened!';
IP := Mask + IntToStr(Byte(p^));
A.sin_family := AF_INET;
A.sin_addr.S_addr := inet_addr(pchar(IP));
A.sin_port := htons(port);
S := socket(AF_INET, SOCK_STREAM, 0);
if S=INVALID_SOCKET then
Exit;
if connect(S, A, sizeof(A)) = 0 then
begin
Send(S, Buf[1], Length(Buf), 0);
Form1.Memo1.Lines.Add(IP);
end;
CloseSocket(S);
except
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
I : Byte;
T : DWord;
WSA : WSAData;
begin
WSAStartUp($101, WSA);
Memo1.Lines.Clear;
for I := 0 to 255 do
begin
a[I] := I;
BeginThread(nil, 1024, @RunThread, @a[I], 0, T);
end;
end;
end.