38 |
|
|
39 |
package java.net; |
package java.net; |
40 |
|
|
|
import gnu.classpath.Configuration; |
|
|
|
|
41 |
import java.util.Enumeration; |
import java.util.Enumeration; |
42 |
import java.util.Vector; |
import java.util.Vector; |
43 |
|
|
53 |
*/ |
*/ |
54 |
public final class NetworkInterface |
public final class NetworkInterface |
55 |
{ |
{ |
|
static |
|
|
{ |
|
|
if (Configuration.INIT_LOAD_LIBRARY) |
|
|
System.loadLibrary("javanet"); |
|
|
} |
|
|
|
|
56 |
private String name; |
private String name; |
57 |
private Vector inetAddresses; |
private Vector inetAddresses; |
58 |
|
|
63 |
this.inetAddresses.add(address); |
this.inetAddresses.add(address); |
64 |
} |
} |
65 |
|
|
|
private static native Vector getRealNetworkInterfaces() |
|
|
throws SocketException; |
|
|
|
|
66 |
/** |
/** |
67 |
* Returns the name of the network interface |
* Returns the name of the network interface |
68 |
* |
* |
134 |
public static NetworkInterface getByName(String name) |
public static NetworkInterface getByName(String name) |
135 |
throws SocketException |
throws SocketException |
136 |
{ |
{ |
137 |
Vector networkInterfaces = getRealNetworkInterfaces(); |
Vector networkInterfaces = VMNetworkInterface.getInterfaces(); |
138 |
|
|
139 |
for (Enumeration e = networkInterfaces.elements(); e.hasMoreElements();) |
for (Enumeration e = networkInterfaces.elements(); e.hasMoreElements();) |
140 |
{ |
{ |
161 |
public static NetworkInterface getByInetAddress(InetAddress addr) |
public static NetworkInterface getByInetAddress(InetAddress addr) |
162 |
throws SocketException |
throws SocketException |
163 |
{ |
{ |
164 |
Vector networkInterfaces = getRealNetworkInterfaces(); |
Vector networkInterfaces = VMNetworkInterface.getInterfaces(); |
165 |
|
|
166 |
for (Enumeration interfaces = networkInterfaces.elements(); |
for (Enumeration interfaces = networkInterfaces.elements(); |
167 |
interfaces.hasMoreElements();) |
interfaces.hasMoreElements();) |
188 |
*/ |
*/ |
189 |
public static Enumeration getNetworkInterfaces() throws SocketException |
public static Enumeration getNetworkInterfaces() throws SocketException |
190 |
{ |
{ |
191 |
Vector networkInterfaces = getRealNetworkInterfaces(); |
Vector networkInterfaces = VMNetworkInterface.getInterfaces(); |
192 |
|
|
193 |
if (networkInterfaces.isEmpty()) |
if (networkInterfaces.isEmpty()) |
194 |
return null; |
return null; |