Board index » delphi » Scan network for server port

Scan network for server port

Is there a way when a program starts to scan a network to see if a certain
port is listening? I want to create a client program that connects to a
third party server program without having to configure the IP address of the
server ahead of time. I have seen something similar to this in installshield
but I am not sure how they did it. I have no control over modifications to
the server program.
 

Re:Scan network for server port


The usual way is to send a packet to the port and check the response.

Against non-hardened systems sending a UDP packet packet to a UDP port that
isn't usually yields a ICMP Type3 code 0 (Port Unreachable) message being
returned to the sender.  With TCP you usually get packet with the RST flag
set (typically its actually ACK, RST).  Hardened systems (either through
personal firewalls or via a network level firewall) will usually not respond
at all.

I don't know how you'd go about checking for this with Indy though.

HTH

Quote
"Delphi Dude" <delp...@NoSpam.charter.net> wrote in message

news:3e8118e1@newsgroups.borland.com...
Quote
> Is there a way when a program starts to scan a network to see if a certain
> port is listening? I want to create a client program that connects to a
> third party server program without having to configure the IP address of
the
> server ahead of time. I have seen something similar to this in
installshield
> but I am not sure how they did it. I have no control over modifications to
> the server program.

Re:Scan network for server port


Just loop through the subnet you want to scan and try and connect with
Tidtcpclient, if you can connect on a particular port there is something
listening.
It's simple actually.

Say you wanted to scan all the addresses in 192.168.1.x  for VNC servers
that run on port 5900

for x: = 2 to 254 do
   begin
            hosttoscan:= 192.168.1.+inTostr(x);
            myclient.host:= hosttoscan;
            myclient.port:= 5900;
            myclient.connect(2000);
            try
                    if myclient.connected then
                        //somthing listening, more than likely a VNC server
            except
                        //if nothing listening then you will end up here
            end;

    end;

Get the idea :-)

You can also use threads and search entire class b subnets in a few seconds.

I actually have a demo I did that will scan entire subnets  if I find it I
will post a link to it.

Tony Caduto

Quote
"Delphi Dude" <delp...@NoSpam.charter.net> wrote in message

news:3e8118e1@newsgroups.borland.com...
Quote
> Is there a way when a program starts to scan a network to see if a certain
> port is listening? I want to create a client program that connects to a
> third party server program without having to configure the IP address of
the
> server ahead of time. I have seen something similar to this in
installshield
> but I am not sure how they did it. I have no control over modifications to
> the server program.

Re:Scan network for server port


Quote

> I actually have a demo I did that will scan entire subnets  if I find it I
> will post a link to it.

Did you happen to find that demo?  i would like to check it out if
possible :)

--
Jack Mays

Re:Scan network for server port


Sorry, i didn't have time but it is just like the example I gave earlier,
just with nested for loops to handle bigger subnets and threads.

Tony

Quote
"Jack Mays" <jackm...@NOSPAM.earthlink.net> wrote in message

news:3E83362B.2060605@NOSPAM.earthlink.net...
Quote

> > I actually have a demo I did that will scan entire subnets  if I find it
I
> > will post a link to it.

> Did you happen to find that demo?  i would like to check it out if
> possible :)

> --
> Jack Mays

Other Threads