APIdia Launch Partner
Top Inners Fields Constructors Methods
com.sun.jndi.dns

pack-priv Class DNSDatagramChannelFactory

extends Object
Class Inheritance
Imports
java.io.IOException, java.net.DatagramSocket, .ProtocolFamily, .InetSocketAddress, java.nio.channels.DatagramChannel, java.util.Objects, .Random

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
DNSDatagramChannelFactory.EphemeralPortRange

The dynamic allocation port range (aka ephemeral ports), as configured on the system.

pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv final int
pack-priv final ProtocolFamily
pack-priv static final int
pack-priv final DNSDatagramChannelFactory.PortHistory
pack-priv int
pack-priv int
pack-priv static final int
pack-priv final Random
pack-priv int
pack-priv static final int
pack-priv final int
pack-priv int

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
pack-priv
DNSDatagramChannelFactory(Random random, ProtocolFamily family, int deviation, int threshold)

Method Summary

Modifier and TypeMethod and Description
private boolean
farEnough(int port)

private static int
private static int
pack-priv synchronized boolean
pack-priv synchronized boolean
pack-priv synchronized boolean
public synchronized DatagramChannel

Returns:

A new DatagramChannel bound to a random port.
open
()

Opens a datagram socket listening to the wildcard address on a random port.

private DatagramChannel
private DatagramChannel
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BIT_DEVIATIONback to summary
pack-priv static final int BIT_DEVIATION
DEVIATIONback to summary
pack-priv static final int DEVIATION
deviationback to summary
pack-priv final int deviation
familyback to summary
pack-priv final ProtocolFamily family
HISTORYback to summary
pack-priv static final int HISTORY
historyback to summary
pack-priv final DNSDatagramChannelFactory.PortHistory history
lastportback to summary
pack-priv int lastport
lastSystemAllocatedback to summary
pack-priv int lastSystemAllocated
MAX_RANDOM_TRIESback to summary
pack-priv static final int MAX_RANDOM_TRIES
randomback to summary
pack-priv final Random random
suitablePortCountback to summary
pack-priv int suitablePortCount
THRESHOLDback to summary
pack-priv static final int THRESHOLD
thresholdCountback to summary
pack-priv final int thresholdCount
unsuitablePortCountback to summary
pack-priv int unsuitablePortCount

Constructor Detail

DNSDatagramChannelFactoryback to summary
pack-priv DNSDatagramChannelFactory()
DNSDatagramChannelFactoryback to summary
pack-priv DNSDatagramChannelFactory(Random random)
DNSDatagramChannelFactoryback to summary
pack-priv DNSDatagramChannelFactory(Random random, ProtocolFamily family, int deviation, int threshold)

Method Detail

farEnoughback to summary
private boolean farEnough(int port)
findFirstFreePortback to summary
private static int findFirstFreePort()
getLocalPortback to summary
private static int getLocalPort(DatagramChannel dc) throws IOException
isUndecidedback to summary
pack-priv synchronized boolean isUndecided()
isUsingJavaPortRandomizationback to summary
pack-priv synchronized boolean isUsingJavaPortRandomization()
isUsingNativePortRandomizationback to summary
pack-priv synchronized boolean isUsingNativePortRandomization()
openback to summary
public synchronized DatagramChannel open() throws IOException

Opens a datagram socket listening to the wildcard address on a random port. If the underlying OS supports UDP port randomization out of the box (if binding a socket to port 0 binds it to a random port) then the underlying OS implementation is used. Otherwise, this method will allocate and bind a socket on a randomly selected ephemeral port in the dynamic range.

Returns:DatagramChannel

A new DatagramChannel bound to a random port.

Exceptions
IOException:
if the socket cannot be created.
openDefaultback to summary
private DatagramChannel openDefault() throws IOException
openRandomback to summary
private DatagramChannel openRandom() throws IOException
com.sun.jndi.dns back to summary

pack-priv final Class DNSDatagramChannelFactory.EphemeralPortRange

extends Object
Class Inheritance
  • java.lang.Object
  • com.sun.jndi.dns.DNSDatagramChannelFactory.EphemeralPortRange

The dynamic allocation port range (aka ephemeral ports), as configured on the system. Use nested class for lazy evaluation.

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOWERback to summary
pack-priv static final int LOWER
RANGEback to summary
pack-priv static final int RANGE
UPPERback to summary
pack-priv static final int UPPER

Constructor Detail

EphemeralPortRangeback to summary
private EphemeralPortRange()
com.sun.jndi.dns back to summary

pack-priv final Class DNSDatagramChannelFactory.PortHistory

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv int
pack-priv final int[]
pack-priv final Random

Constructor Summary

AccessConstructor and Description
pack-priv
PortHistory(int capacity, Random random)

Method Summary

Modifier and TypeMethod and Description
public boolean
add(int port)

public boolean
contains(int port)

public boolean
offer(int port)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

capacityback to summary
pack-priv final int capacity
indexback to summary
pack-priv int index
portsback to summary
pack-priv final int[] ports
randomback to summary
pack-priv final Random random

Constructor Detail

PortHistoryback to summary
pack-priv PortHistory(int capacity, Random random)

Method Detail

addback to summary
public boolean add(int port)
containsback to summary
public boolean contains(int port)
offerback to summary
public boolean offer(int port)