public interface NetworkAddressFactory
An implementation has to be thread-safe.
Modifier and Type | Field and Description |
---|---|
static String |
SYSTEM_PROPERTY_NET_ADDRESSES |
static String |
SYSTEM_PROPERTY_NET_IFACES |
Modifier and Type | Method and Description |
---|---|
Short |
getAddressNetworkPrefixLength(InetAddress inetAddress) |
Iterator<InetAddress> |
getBindAddresses()
The caller might
remove() an address if initialization fails. |
InetAddress |
getBroadcastAddress(InetAddress inetAddress) |
byte[] |
getHardwareAddress(InetAddress inetAddress) |
InetAddress |
getLocalAddress(NetworkInterface networkInterface,
boolean isIPv6,
InetAddress remoteAddress)
Best-effort attempt finding a reachable local address for a given remote host.
|
InetAddress |
getMulticastGroup() |
int |
getMulticastPort() |
Iterator<NetworkInterface> |
getNetworkInterfaces()
The caller might
remove() an interface if initialization fails. |
int |
getStreamListenPort() |
boolean |
hasUsableNetwork() |
void |
logInterfaceInformation()
For debugging, logs all "usable" network interface(s) details with INFO level.
|
static final String SYSTEM_PROPERTY_NET_IFACES
static final String SYSTEM_PROPERTY_NET_ADDRESSES
InetAddress getMulticastGroup()
int getMulticastPort()
int getStreamListenPort()
Iterator<NetworkInterface> getNetworkInterfaces()
remove()
an interface if initialization fails.Iterator<InetAddress> getBindAddresses()
remove()
an address if initialization fails.boolean hasUsableNetwork()
true
if there is at least one usable network interface and bind address.Short getAddressNetworkPrefixLength(InetAddress inetAddress)
null
.byte[] getHardwareAddress(InetAddress inetAddress)
inetAddress
- An address of a local network interface.null
if no
hardware address could be obtained.InetAddress getBroadcastAddress(InetAddress inetAddress)
inetAddress
- An address of a local network interface.null
if no
broadcast address could be obtained.InetAddress getLocalAddress(NetworkInterface networkInterface, boolean isIPv6, InetAddress remoteAddress) throws IllegalStateException
This method is called whenever a multicast datagram has been received. We need to be able to communicate with the sender using UDP unicast and we need to tell the sender how we are reachable with TCP requests. We need a local address that is in the same subnet as the senders address, that is reachable from the senders point of view.
networkInterface
- The network interface to examine.isIPv6
- True if the given remote address is an IPv6 address.remoteAddress
- The remote address for which to find a local address in the same subnet.IllegalStateException
- If no local address reachable by the remote address has been found.void logInterfaceInformation()
Copyright © 2016 4th Line GmbH, Switzerland. All rights reserved.