/etc/networks entry

T

T

Hi
Would appreciate if somebody can tell me how to obtain a network entry in
/etc/networks. Which class or classes should I use.

Thanks in advance

Cheers
T
 
G

Gordon Beaton

Would appreciate if somebody can tell me how to obtain a network
entry in /etc/networks. Which class or classes should I use.

It isn't clear from your post exactly what you want to do, or what
/etc/networks contains (I don't have such a file on any of my Solaris
or Linux boxes).

If you just want to read the file, use e.g. an InputStreamReader
wrapped around a FileInputStream.

Depending on what it is you're trying to do, java.net.NetworkInterface
might offer a better solution.

/gordon
 
T

T

It isn't clear from your post exactly what you want to do, or what
/etc/networks contains (I don't have such a file on any of my Solaris or
Linux boxes).

If you just want to read the file, use e.g. an InputStreamReader wrapped
around a FileInputStream.

Depending on what it is you're trying to do, java.net.NetworkInterface
might offer a better solution.

/gordon

Hi gordon
Thanks, sorry for begin ambiguous. The application runs on a solaris
machine with 2 nic.
In /etc/networks, there are 2 entries,
clientside 192.168.1.0
serverside 101.2.4.0

The application suppose to grep clientside from /etc/networks and
broadcast to 192.168.1.0.

I tried using java.net.NetworkInterface.getgetByName("clientside"). It
returns null.

I agreed another approach is using FileInputStream.

It be neater using network classes.

Anyway suggestion

Cheers
T
 
R

Rogan Dawes

T said:
Hi gordon
Thanks, sorry for begin ambiguous. The application runs on a solaris
machine with 2 nic.
In /etc/networks, there are 2 entries,
clientside 192.168.1.0
serverside 101.2.4.0

The application suppose to grep clientside from /etc/networks and
broadcast to 192.168.1.0.

I tried using java.net.NetworkInterface.getgetByName("clientside"). It
returns null.

I agreed another approach is using FileInputStream.

It be neater using network classes.

Anyway suggestion

Cheers
T

NetworkInterface.getByName(String) does not get a *network address*, it
gets a *network interface*, which is a very different thing.

Read the Java Doc more carefully.

http://java.sun.com/j2se/1.4.2/docs/api/java/net/NetworkInterface.html#getByName(java.lang.String)

What you have in the /etc/networks is, as you expect, a network address.
Note that the broadcast address for that network is NOT 192.168.1.0, it
could be any (power of 2)-1 between 3 and 255, depending on the netmask.

Rogan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top