Board index » delphi » Indy 8.0 -- Socket Error # 10061

Indy 8.0 -- Socket Error # 10061

I am using TIdTCPClient. What I am trying to do is scan a subnet for servers
listening on port 9100 and query some info but when I come across a
"connection rejection" socket error #10061  I'm thrown out of the loop and
cant scan the next server. How do I by pass exceptions in the Indy TCP
client? I need something like the VB infamous "Resume Next". any Idea's?

procedure TForm2.Button1Click(Sender: TObject);
var
    i: integer;
    thisIP,subnet: String;
begin

subnet:= txtSubnet.text;
Delete(subnet,LastDelimiter('.',subnet),Length(subnet));
subnet:=subnet + '.';
for i:= 1 to 255 do
begin
   ThisIP := subnet + IntToStr(i);
   if not CliSocket.Connected then begin

        CliSocket.Port  := 9100;
        CliSocket.host  := thisIP;
        Edit1.Text:= 'Connecting to ' + thisIP+'...';
   try
   CliSocket.Connect;
   except
   on EIdSocksError do continue;// Doesn't work
   end;
   end;

end;
end;

 

Re:Indy 8.0 -- Socket Error # 10061


Quote
>   try
>   CliSocket.Connect;
>   except
>   on EIdSocksError do continue;// Doesn't work

You don't need to put continue in there. just trap the exception.

Re:Indy 8.0 -- Socket Error # 10061


I do not know the TIdTCPClient, but setting the onerror event en clearing
the errorcode does the trick with the Tclientsocket.
If you are looking for your own servers, a neater way is an UDP
client/listener solution. You simply broadcast a message and your servers
can reply to the sender on a standard port, say 9101.

Quote
"Eric Erhardt" <e...@printperpage.com> wrote in message

news:3b16557c$1_1@dnews...
Quote
> I am using TIdTCPClient. What I am trying to do is scan a subnet for
servers
> listening on port 9100 and query some info but when I come across a
> "connection rejection" socket error #10061  I'm thrown out of the loop and
> cant scan the next server. How do I by pass exceptions in the Indy TCP
> client? I need something like the VB infamous "Resume Next". any Idea's?

> procedure TForm2.Button1Click(Sender: TObject);
> var
>     i: integer;
>     thisIP,subnet: String;
> begin

> subnet:= txtSubnet.text;
> Delete(subnet,LastDelimiter('.',subnet),Length(subnet));
> subnet:=subnet + '.';
> for i:= 1 to 255 do
> begin
>    ThisIP := subnet + IntToStr(i);
>    if not CliSocket.Connected then begin

>         CliSocket.Port  := 9100;
>         CliSocket.host  := thisIP;
>         Edit1.Text:= 'Connecting to ' + thisIP+'...';
>    try
>    CliSocket.Connect;
>    except
>    on EIdSocksError do continue;// Doesn't work
>    end;
>    end;

> end;
> end;

Other Threads