public class AndroidNetworkAddressFactory extends NetworkAddressFactoryImpl
bindAddresses, DEFAULT_TCP_HTTP_LISTEN_PORT, networkInterfaces, streamListenPort, useAddresses, useInterfaces
SYSTEM_PROPERTY_NET_ADDRESSES, SYSTEM_PROPERTY_NET_IFACES
Constructor and Description |
---|
AndroidNetworkAddressFactory(int streamListenPort) |
Modifier and Type | Method and Description |
---|---|
protected void |
discoverNetworkInterfaces() |
InetAddress |
getLocalAddress(NetworkInterface networkInterface,
boolean isIPv6,
InetAddress remoteAddress)
Best-effort attempt finding a reachable local address for a given remote host.
|
protected boolean |
isUsableAddress(NetworkInterface networkInterface,
InetAddress address)
Validation of every discovered local address.
|
protected boolean |
requiresNetworkInterface() |
discoverBindAddresses, getAddressNetworkPrefixLength, getBindAddresses, getBindAddressInSubnetOf, getBroadcastAddress, getHardwareAddress, getInetAddresses, getInterfaceAddresses, getMulticastGroup, getMulticastPort, getNetworkInterfaces, getStreamListenPort, hasUsableNetwork, isInSubnet, isUsableNetworkInterface, logInterfaceInformation, logInterfaceInformation
public AndroidNetworkAddressFactory(int streamListenPort)
protected boolean requiresNetworkInterface()
requiresNetworkInterface
in class NetworkAddressFactoryImpl
true
(the default) if a MissingNetworkInterfaceException
should be thrownprotected boolean isUsableAddress(NetworkInterface networkInterface, InetAddress address)
NetworkAddressFactoryImpl
Override this method to customize which network addresses are used.
The given implementation ignores addresses which are
isUsableAddress
in class NetworkAddressFactoryImpl
networkInterface
- The interface to validate.address
- The address of this interface to validate.public InetAddress getLocalAddress(NetworkInterface networkInterface, boolean isIPv6, InetAddress remoteAddress)
NetworkAddressFactory
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.
getLocalAddress
in interface NetworkAddressFactory
getLocalAddress
in class NetworkAddressFactoryImpl
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.protected void discoverNetworkInterfaces() throws InitializationException
discoverNetworkInterfaces
in class NetworkAddressFactoryImpl
InitializationException
Copyright © 2016 4th Line GmbH, Switzerland. All rights reserved.