How to get host's subnet mask or net address for broadcast sockets?

How to get host's subnet mask or net address for broadcast sockets?

Post by y721 » Tue, 12 Jun 2001 10:43:25



Hi,

I can use 255.255.255.255 broadcast address on Windows 98, when I broadcast
a udp packet.

But I have to use netaddress of the host on Linux.
Is there a way that I can get net address of the host?
or subnet mask so that I can send broadcast packet?

Thank you.

steve

 
 
 

How to get host's subnet mask or net address for broadcast sockets?

Post by Nithyanandha » Tue, 12 Jun 2001 12:11:02



> Hi,

> I can use 255.255.255.255 broadcast address on Windows 98, when I broadcast
> a udp packet.

> But I have to use netaddress of the host on Linux.
> Is there a way that I can get net address of the host?
> or subnet mask so that I can send broadcast packet?

'ifconfig -a'

--Nithyanand.
  Siemens, Bangalore, India.

 
 
 

How to get host's subnet mask or net address for broadcast sockets?

Post by y721 » Tue, 12 Jun 2001 13:16:03


I meant using socket API.




> > Hi,

> > I can use 255.255.255.255 broadcast address on Windows 98, when I
broadcast
> > a udp packet.

> > But I have to use netaddress of the host on Linux.
> > Is there a way that I can get net address of the host?
> > or subnet mask so that I can send broadcast packet?

> 'ifconfig -a'

> --Nithyanand.
>   Siemens, Bangalore, India.

 
 
 

How to get host's subnet mask or net address for broadcast sockets?

Post by Joe Halpi » Tue, 12 Jun 2001 23:10:25



> Hi,

> I can use 255.255.255.255 broadcast address on Windows 98, when I broadcast
> a udp packet.

> But I have to use netaddress of the host on Linux.
> Is there a way that I can get net address of the host?
> or subnet mask so that I can send broadcast packet?

Some systems have an ioctl for accessing the routing table. I'm not
familiar with it personally, but check your system man pages. You
might also get something out of looking at the source for route or
ifconfig. Linux and *BSD versions are available on the net.

Joe

 
 
 

How to get host's subnet mask or net address for broadcast sockets?

Post by Nithyanandha » Wed, 13 Jun 2001 01:26:18



> I meant using socket API.

> > > I can use 255.255.255.255 broadcast address on Windows 98, when I
> broadcast a udp packet.
> > > But I have to use netaddress of the host on Linux.
> > > Is there a way that I can get net address of the host?
> > > or subnet mask so that I can send broadcast packet?

> > 'ifconfig -a'

Read the entries in  /etc/inet/netmasks . No built-in look-up function
provided to read this data file

'man getnetbyname' can also be helpful  .

--Nithyanand.
  Siemens, Bangalore, India.

 
 
 

1. Getting IP Address and Subnet Mask of the local machine in network.

Hi,
  I have the name of the remote host in my local network. I will get
the IP address of the remote host by using gethostbyname() function.
  I will get the name of the local machine using gethostname. and IP
address by using gethostbyname.

 Now I want to check that the given IP address ( remote host ) is in
my subnet or not. For that I need to get the Subnet Mask of the
network. Is there any API to get the subnet mask of the network ?

Waiting for the response at the earliest.,

Thanks in advance and Regards.


Tally Solutions Pvt. Ltd.

2. You're probably all tired of this... Santa Cruz...

3. calculating network and broadcast from subnet mask

4. How can I hear Wav in Red Hat 6.0?

5. Getting the broadcast address from an open socket

6. PPP?

7. IP Subnet masks, subnetting class C net.

8. Boot fails "Calibrating delay loop.."

9. Apache Virtual Host Subnet masks: Question

10. getting the subnet mask

11. Changing IP addresses and subnet masks on Solaris 5.5.1 - is this okay?

12. Netmask != subnet mask; gateway != router address. Or not?