APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.net

public final Class ExtendedSocketOptions

extends Object
Class Inheritance
Imports
java.io.FileDescriptor, java.net.SocketException, .SocketOption, .StandardProtocolFamily, java.util.Collections, .HashSet, .Set, jdk.internal.access.JavaIOFileDescriptorAccess, .SharedSecrets, jdk.internal.util.OperatingSystem

Defines extended socket options, beyond those defined in java.net.StandardSocketOptions. These options may be platform specific.
Since
1.8

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final Set<SocketOption<?>>
private static final JavaIOFileDescriptorAccess
private static final boolean
public static final SocketOption<Boolean>
IP_DONTFRAGMENT

Disable IP packet fragmentation.

private static final boolean
private static final boolean
private static final boolean
private static final ExtendedSocketOptions.PlatformSocketOptions
private static final boolean
public static final SocketOption<Integer>
SO_INCOMING_NAPI_ID

Identifies the receive queue that the last incoming packet for the socket was received on.

public static final SocketOption<UnixDomainPrincipal>
SO_PEERCRED

Unix Domain peer credentials.

public static final SocketOption<Integer>
TCP_KEEPCOUNT

Keep-Alive retransmission maximum limit.

public static final SocketOption<Integer>
TCP_KEEPIDLE

Keep-Alive idle time.

public static final SocketOption<Integer>
TCP_KEEPINTERVAL

Keep-Alive retransmission interval time.

public static final SocketOption<Boolean>
TCP_QUICKACK

Disable Delayed Acknowledgements.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static int
private static boolean
getIpDontFragment(FileDescriptor fd, boolean isIPv6)

private static Object
private static Object
private static int
private static int
private static int
pack-priv static Set<SocketOption<?>>
private static void
setIpDontFragment(FileDescriptor fd, boolean value, boolean isIPv6)

private static void
setQuickAckOption(FileDescriptor fd, boolean enable)

private static void
private static void
private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

extendedOptionsback to summary
private static final Set<SocketOption<?>> extendedOptions
fdAccessback to summary
private static final JavaIOFileDescriptorAccess fdAccess
incomingNapiIdOptSupportedback to summary
private static final boolean incomingNapiIdOptSupported
IP_DONTFRAGMENTback to summary
public static final SocketOption<Boolean> IP_DONTFRAGMENT

Disable IP packet fragmentation.

The value of this socket option is a Boolean that represents whether the option is enabled or disabled. When true fragmentation of outgoing IPv4 and IPv6 packets does not occur. This option can only be used with datagram sockets. When set, care must be taken to limit outgoing packet sizes to the local MTU. Depending on the implementation and the network interface, packets larger than the MTU may be sent or dropped silently or dropped with an exception thrown. For IPv6 sockets it is system dependent whether the option also applies to datagrams sent to IPv4 addresses.

API Note

For IPv4 this option sets the DF (Do not Fragment) flag in the IP packet header. This instructs intermediate routers to not fragment the packet. IPv6 routers never fragment packets. Instead, fragmentation is handled by the sending and receiving nodes exclusively. Setting this option for an IPv6 socket ensures that packets to be sent are never fragmented, in which case, the local network MTU must be observed.

Since
19
ipDontFragmentSupportedback to summary
private static final boolean ipDontFragmentSupported
keepAliveOptSupportedback to summary
private static final boolean keepAliveOptSupported
peerCredentialsSupportedback to summary
private static final boolean peerCredentialsSupported
platformSocketOptionsback to summary
private static final ExtendedSocketOptions.PlatformSocketOptions platformSocketOptions
quickAckSupportedback to summary
private static final boolean quickAckSupported
SO_INCOMING_NAPI_IDback to summary
public static final SocketOption<Integer> SO_INCOMING_NAPI_ID

Identifies the receive queue that the last incoming packet for the socket was received on.

The value of this socket option is a positive Integer that identifies a receive queue that the application can use to split the incoming flows among threads based on the queue identifier. The value is 0 when the socket is not bound, a packet has not been received, or more generally, when there is no receive queue to identify. The socket option is supported by both stream-oriented and datagram-oriented sockets.

The socket option is read-only and an attempt to set the socket option will throw SocketException.

API Note

Network devices may have multiple queues or channels to transmit and receive network packets. The SO_INCOMING_NAPI_ID socket option provides a hint to the application to indicate the receive queue on which an incoming socket connection or packets for that connection are directed to. An application may take advantage of this by handling all socket connections assigned to a specific queue on one thread.

Since
15
SO_PEERCREDback to summary
public static final SocketOption<UnixDomainPrincipal> SO_PEERCRED

Unix Domain peer credentials.

The value of this socket option is a UnixDomainPrincipal that represents the credentials of a peer connected to a Unix Domain socket. The credentials are those that applied at the time the socket was first connected or accepted.

The socket option is read-only and an attempt to set the socket option will throw SocketException. SocketException is also thrown when attempting to get the value of the socket option on an unconnected Unix Domain socket.

Since
16
TCP_KEEPCOUNTback to summary
public static final SocketOption<Integer> TCP_KEEPCOUNT

Keep-Alive retransmission maximum limit.

The value of this socket option is an Integer that is the maximum number of keep-alive probes to be sent. The socket option is specific to stream-oriented sockets using the TCP/IP protocol. The exact semantics of this socket option are system dependent.

When the SO_KEEPALIVE option is enabled, TCP probes a connection that has been idle for some amount of time. If the remote system does not respond to a keep-alive probe, TCP retransmits the probe a certain number of times before a connection is considered to be broken. The default value for this keep-alive probe retransmit limit is system dependent, but is typically 8. The TCP_KEEPCOUNT option can be used to affect this value for a given socket.

Since
11
TCP_KEEPIDLEback to summary
public static final SocketOption<Integer> TCP_KEEPIDLE

Keep-Alive idle time.

The value of this socket option is an Integer that is the number of seconds of idle time before keep-alive initiates a probe. The socket option is specific to stream-oriented sockets using the TCP/IP protocol. The exact semantics of this socket option are system dependent.

When the SO_KEEPALIVE option is enabled, TCP probes a connection that has been idle for some amount of time. The default value for this idle period is system dependent, but is typically 2 hours. The TCP_KEEPIDLE option can be used to affect this value for a given socket.

Since
11
TCP_KEEPINTERVALback to summary
public static final SocketOption<Integer> TCP_KEEPINTERVAL

Keep-Alive retransmission interval time.

The value of this socket option is an Integer that is the number of seconds to wait before retransmitting a keep-alive probe. The socket option is specific to stream-oriented sockets using the TCP/IP protocol. The exact semantics of this socket option are system dependent.

When the SO_KEEPALIVE option is enabled, TCP probes a connection that has been idle for some amount of time. If the remote system does not respond to a keep-alive probe, TCP retransmits the probe after some amount of time. The default value for this retransmission interval is system dependent, but is typically 75 seconds. The TCP_KEEPINTERVAL option can be used to affect this value for a given socket.

Since
11
TCP_QUICKACKback to summary
public static final SocketOption<Boolean> TCP_QUICKACK

Disable Delayed Acknowledgements.

This socket option can be used to reduce or disable delayed acknowledgments (ACKs). When TCP_QUICKACK is enabled, ACKs are sent immediately, rather than delayed if needed in accordance to normal TCP operation. This option is not permanent, it only enables a switch to or from TCP_QUICKACK mode. Subsequent operations of the TCP protocol will once again disable/enable TCP_QUICKACK mode depending on internal protocol processing and factors such as delayed ACK timeouts occurring and data transfer, therefore this option needs to be set with setOption after each operation of TCP on a given socket.

The value of this socket option is a Boolean that represents whether the option is enabled or disabled. The socket option is specific to stream-oriented sockets using the TCP/IP protocol. The exact semantics of this socket option are socket type and system dependent.

Since
10

Constructor Detail

ExtendedSocketOptionsback to summary
private ExtendedSocketOptions()

Method Detail

getIncomingNapiIdback to summary
private static int getIncomingNapiId(FileDescriptor fd) throws SocketException
getIpDontFragmentback to summary
private static boolean getIpDontFragment(FileDescriptor fd, boolean isIPv6) throws SocketException
getQuickAckOptionback to summary
private static Object getQuickAckOption(FileDescriptor fd) throws SocketException
getSoPeerCredback to summary
private static Object getSoPeerCred(FileDescriptor fd) throws SocketException
getTcpKeepAliveIntvlback to summary
private static int getTcpKeepAliveIntvl(FileDescriptor fd) throws SocketException
getTcpKeepAliveProbesback to summary
private static int getTcpKeepAliveProbes(FileDescriptor fd) throws SocketException
getTcpKeepAliveTimeback to summary
private static int getTcpKeepAliveTime(FileDescriptor fd) throws SocketException
optionsback to summary
pack-priv static Set<SocketOption<?>> options()
setIpDontFragmentback to summary
private static void setIpDontFragment(FileDescriptor fd, boolean value, boolean isIPv6) throws SocketException
setQuickAckOptionback to summary
private static void setQuickAckOption(FileDescriptor fd, boolean enable) throws SocketException
setTcpKeepAliveIntvlback to summary
private static void setTcpKeepAliveIntvl(FileDescriptor fd, int value) throws SocketException
setTcpKeepAliveProbesback to summary
private static void setTcpKeepAliveProbes(FileDescriptor fd, int value) throws SocketException
setTcpKeepAliveTimeback to summary
private static void setTcpKeepAliveTime(FileDescriptor fd, int value) throws SocketException
jdk.net back to summary

private Class ExtendedSocketOptions.ExtSocketOption<T>

extends Object
implements SocketOption<T>
Class Inheritance
All Implemented Interfaces
java.net.SocketOption

Field Summary

Modifier and TypeField and Description
private final String
private final Class<T>

Constructor Summary

AccessConstructor and Description
pack-priv
ExtSocketOption(String name, Class<T> type)

Method Summary

Modifier and TypeMethod and Description
public String
name()

Implements java.net.SocketOption.name.

Returns the name of the socket option.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Class<T>
type()

Implements java.net.SocketOption.type.

Returns the type of the socket option value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

nameback to summary
private final String name
typeback to summary
private final Class<T> type

Constructor Detail

ExtSocketOptionback to summary
pack-priv ExtSocketOption(String name, Class<T> type)

Method Detail

nameback to summary
public String name()

Implements java.net.SocketOption.name.

Doc from java.net.SocketOption.name.

Returns the name of the socket option.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
typeback to summary
public Class<T> type()

Implements java.net.SocketOption.type.

Doc from java.net.SocketOption.type.

Returns the type of the socket option value.

Annotations
@Override
jdk.net back to summary

pack-priv Class ExtendedSocketOptions.PlatformSocketOptions

extends Object
Class Inheritance
Known Direct Subclasses
jdk.net.LinuxSocketOptions

Field Summary

Modifier and TypeField and Description
private static final ExtendedSocketOptions.PlatformSocketOptions

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private static ExtendedSocketOptions.PlatformSocketOptions
pack-priv static ExtendedSocketOptions.PlatformSocketOptions
get()

pack-priv int
pack-priv boolean
getIpDontFragment(int fd, boolean isIPv6)

pack-priv boolean
getQuickAck(int fd)

pack-priv UnixDomainPrincipal
getSoPeerCred(int fd)

pack-priv int
pack-priv int
pack-priv int
pack-priv boolean
pack-priv boolean
pack-priv boolean
private static ExtendedSocketOptions.PlatformSocketOptions
pack-priv boolean
pack-priv boolean
pack-priv void
setIpDontFragment(int fd, final boolean value, boolean isIPv6)

pack-priv void
setQuickAck(int fd, boolean on)

pack-priv void
setTcpKeepAliveIntvl(int fd, final int value)

pack-priv void
setTcpKeepAliveProbes(int fd, final int value)

pack-priv void
setTcpKeepAliveTime(int fd, final int value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
private static final ExtendedSocketOptions.PlatformSocketOptions instance

Constructor Detail

PlatformSocketOptionsback to summary
protected PlatformSocketOptions()

Method Detail

createback to summary
private static ExtendedSocketOptions.PlatformSocketOptions create()
getback to summary
pack-priv static ExtendedSocketOptions.PlatformSocketOptions get()
getIncomingNapiIdback to summary
pack-priv int getIncomingNapiId(int fd) throws SocketException
getIpDontFragmentback to summary
pack-priv boolean getIpDontFragment(int fd, boolean isIPv6) throws SocketException
getQuickAckback to summary
pack-priv boolean getQuickAck(int fd) throws SocketException
getSoPeerCredback to summary
pack-priv UnixDomainPrincipal getSoPeerCred(int fd) throws SocketException
getTcpKeepAliveIntvlback to summary
pack-priv int getTcpKeepAliveIntvl(int fd) throws SocketException
getTcpKeepAliveProbesback to summary
pack-priv int getTcpKeepAliveProbes(int fd) throws SocketException
getTcpKeepAliveTimeback to summary
pack-priv int getTcpKeepAliveTime(int fd) throws SocketException
incomingNapiIdSupportedback to summary
pack-priv boolean incomingNapiIdSupported()
ipDontFragmentSupportedback to summary
pack-priv boolean ipDontFragmentSupported()
keepAliveOptionsSupportedback to summary
pack-priv boolean keepAliveOptionsSupported()
newInstanceback to summary
private static ExtendedSocketOptions.PlatformSocketOptions newInstance(String cn)
Annotations
@SuppressWarnings:unchecked
peerCredentialsSupportedback to summary
pack-priv boolean peerCredentialsSupported()
quickAckSupportedback to summary
pack-priv boolean quickAckSupported()
setIpDontFragmentback to summary
pack-priv void setIpDontFragment(int fd, final boolean value, boolean isIPv6) throws SocketException
setQuickAckback to summary
pack-priv void setQuickAck(int fd, boolean on) throws SocketException
setTcpKeepAliveIntvlback to summary
pack-priv void setTcpKeepAliveIntvl(int fd, final int value) throws SocketException
setTcpKeepAliveProbesback to summary
pack-priv void setTcpKeepAliveProbes(int fd, final int value) throws SocketException
setTcpKeepAliveTimeback to summary
pack-priv void setTcpKeepAliveTime(int fd, final int value) throws SocketException