Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Feb : How can I read the netmask of my network using Delphi7?

www.cryer.info
Managed Newsgroup Archive

How can I read the netmask of my network using Delphi7?

Subject:How can I read the netmask of my network using Delphi7?
Posted by:"Bo Berglund" (bo.berglu..@telia.com)
Date:Tue, 14 Feb 2006 00:23:13

I want to find out on which network the PC which runs my software is
connected.
Specifically I need to find the netmask value. I know how to get the
IP address, but not the netmask.

The reason is that I want to connect to a perticular port server
(hardware gadget) on the network and I can broadcast a UDP command to
make them all report their presence. This way I can get their IP
address and a name property too.
But in order to reach them by TCP socket communication I need to
verify if their IP address is actually within my own PC:s network.
This will be done by anding the IP address of the portserver (received
from the broadcast) and the IP of my own PC with the netmask and
compare the results. If they are the same then I can go ahead and work
with the port server.

So the netmask is important to retrieve, but how?

I use the Indy 9 UDP client component to broadcast the report command.
Is there a way using Windows API or Indy9 to retrieve the netmask on
my own PC?

/Bo

Replies:

www.cryer.info
Managed Newsgroup Archive