public final class NetworkUtil extends Object
Modifier and Type | Method and Description |
---|---|
static String |
dumpLocalNetworkInfo()
Get the local network info as a string
|
static InetAddress |
findLocalAddressViaNetworkInterface() |
static String |
getAgentId(int objectId,
String type) |
static InetAddress |
getLocalAddress()
Get a local, IP4 Address, preferable a non-loopback address which is bound to an interface.
|
static InetAddress |
getLocalAddressWithMulticast()
Get a local address which supports multicast.
|
static List<InetAddress> |
getMulticastAddresses()
Get all local addresses on which a multicast can be send
|
static boolean |
isMulticastSupported()
Check, whether multicast is supported at all by at least one interface
|
static boolean |
isMulticastSupported(InetAddress pAddr)
Check whether the given address' interface supports multicast
|
static boolean |
isMulticastSupported(NetworkInterface pNif)
Check whether the given interface supports multicast and is up
|
static void |
main(String[] args) |
static String |
replaceExpression(String pValue)
Replace expression ${host} and ${ip} with the localhost name or IP in the given string.
|
static String |
sanitizeLocalUrl(String pRequestURL)
Examine the given URL and replace the host with a non-loopback host if possible.
|
public static void main(String[] args) throws UnknownHostException, SocketException
UnknownHostException
SocketException
public static InetAddress getLocalAddress() throws UnknownHostException, SocketException
UnknownHostException
SocketException
public static InetAddress getLocalAddressWithMulticast() throws UnknownHostException, SocketException
UnknownHostException
SocketException
public static InetAddress findLocalAddressViaNetworkInterface()
public static boolean isMulticastSupported() throws SocketException
SocketException
public static boolean isMulticastSupported(NetworkInterface pNif)
pNif
- check whether the given interface supports multicastpublic static boolean isMulticastSupported(InetAddress pAddr) throws SocketException
pAddr
- address to checkSocketException
public static List<InetAddress> getMulticastAddresses() throws SocketException
SocketException
public static String sanitizeLocalUrl(String pRequestURL)
pRequestURL
- url to examine and to updatepublic static String dumpLocalNetworkInfo() throws UnknownHostException, SocketException
UnknownHostException
SocketException
public static String replaceExpression(String pValue)
pValue
- value to examineIllegalArgumentException
- when the expression is unknown or an error occurs when extracting the host nameCopyright © 2016. All rights reserved.