SocketImpl
and DatagramSocketImpl
.
Subclasses of these two classes should override the getOption(int)
and
setOption(int, Object)
methods of this interface in order to support their own options.
The methods and constants defined in this interface are
for implementation only. If you're not subclassing SocketImpl
or
DatagramSocketImpl
, then you won't use these directly. There are
type-safe methods to get/set each of these options in Socket
, ServerSocket
,
DatagramSocket
and MulticastSocket
.
Modifier and Type | Field and Description |
---|---|
public static final int | IP_MULTICAST_IF
See |
public static final int | IP_MULTICAST_IF2
This option is used to both set and fetch the outgoing interface on which the multicast packets are sent. |
public static final int | IP_MULTICAST_LOOP
See |
public static final int | IP_TOS
See |
public static final int | SO_BINDADDR
Fetch the local address binding of a socket. |
public static final int | SO_BROADCAST
See |
public static final int | SO_KEEPALIVE
See |
public static final int | SO_LINGER
See |
public static final int | SO_OOBINLINE
When this option is set, any TCP urgent data received on the socket will be received through the socket input stream. |
public static final int | SO_RCVBUF
See |
public static final int | SO_REUSEADDR
See |
public static final int | SO_REUSEPORT
See |
public static final int | SO_SNDBUF
See |
public static final int | SO_TIMEOUT
This option is used to both set and fetch a timeout value on blocking
|
public static final int | TCP_NODELAY
See |
Modifier and Type | Method and Description |
---|---|
public Object | Returns: the value of the optionan optID)int identifying the option to fetchFetch the value of an option. |
public void |
IP_MULTICAST_IF | back to summary |
---|---|
public static final int IP_MULTICAST_IF See |
IP_MULTICAST_IF2 | back to summary |
---|---|
public static final int IP_MULTICAST_IF2 This option is used to both set and fetch the outgoing interface on which the multicast packets are sent. Useful on hosts with multiple network interfaces, where applications want to use other than the system default. This option supports setting outgoing interfaces with either IPv4 and IPv6 addresses. |
IP_MULTICAST_LOOP | back to summary |
---|---|
public static final int IP_MULTICAST_LOOP See
|
IP_TOS | back to summary |
---|---|
public static final int IP_TOS See
|
SO_BINDADDR | back to summary |
---|---|
public static final int SO_BINDADDR Fetch the local address binding of a socket. This option cannot be set and can only be
fetched. The default local address of a socket is
|
SO_BROADCAST | back to summary |
---|---|
public static final int SO_BROADCAST See
|
SO_KEEPALIVE | back to summary |
---|---|
public static final int SO_KEEPALIVE See
|
SO_LINGER | back to summary |
---|---|
public static final int SO_LINGER See
Set the value to
If this option is enabled then
|
SO_OOBINLINE | back to summary |
---|---|
public static final int SO_OOBINLINE When this option is set, any TCP urgent data received on the socket will be received through the socket input stream. When the option is disabled (which is the default) urgent data is silently discarded.
|
SO_RCVBUF | back to summary |
---|---|
public static final int SO_RCVBUF See |
SO_REUSEADDR | back to summary |
---|---|
public static final int SO_REUSEADDR See |
SO_REUSEPORT | back to summary |
---|---|
public static final int SO_REUSEPORT See
|
SO_SNDBUF | back to summary |
---|---|
public static final int SO_SNDBUF See |
SO_TIMEOUT | back to summary |
---|---|
public static final int SO_TIMEOUT This option is used to both set and fetch a timeout value on blocking
This option must be set prior to entering a blocking operation to take effect. If the
timeout expires and the operation would continue to block, then
|
TCP_NODELAY | back to summary |
---|---|
public static final int TCP_NODELAY See
|
getOption | back to summary |
---|---|
public Object getOption(int optID) throws SocketException Fetch the value of an option. Binary options will return SocketImpl s; ... Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY)); if (noDelay.booleanValue()) { // true if TCP_NODELAY is enabled... ... }
For options that take a particular type as a parameter, this method will return the
parameter's value, else it will return Object o = s.getOption(SO_LINGER); if (o instanceof Integer) { System.out.print("Linger time is " + ((Integer)o).intValue()); } else { // the true type of o is java.lang.Boolean.FALSE; }
|
setOption | back to summary |
---|---|
public void setOption(int optID, Object value) throws SocketException Enable/disable the option specified by SocketImpl s; ... s.setOption(SO_LINGER, Integer.valueOf(10)); // OK - set SO_LINGER w/ timeout of 10 sec. s.setOption(SO_LINGER, Double.valueOf(10)); // ERROR - expects java.lang.Integer Boolean :
s.setOption(TCP_NODELAY, Boolean.TRUE); // OK - enables TCP_NODELAY, a binary option Boolean#FALSE :
s.setOption(TCP_NODELAY, Boolean.FALSE); // OK - disables TCP_NODELAY s.setOption(SO_LINGER, Boolean.FALSE); // OK - disables SO_LINGER Boolean#FALSE implicitly enables it.
|