java.net.SocketOptions |
Known Indirect Subclasses |
Defines an interface for socket implementations to get and set socket
options. It is implemented by the classes SocketImpl
and DatagramSocketImpl
.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | IP_MULTICAST_IF | This option specifies the interface which is used to send multicast packets. | |||||||||
int | IP_MULTICAST_IF2 | This option can be used to set one specific interface on a multihomed host on which incoming connections are accepted. | |||||||||
int | IP_MULTICAST_LOOP | This option specifies whether the local loopback of multicast packets is enabled or disabled. | |||||||||
int | IP_TOS | This option specifies the value for the Type-of-Service (TOS) field of the IP header. | |||||||||
int | SO_BINDADDR | This option can be used to set one specific interface on a multihomed host on which incoming connections are accepted. | |||||||||
int | SO_BROADCAST | This option can be used to enable broadcasting on datagram sockets. | |||||||||
int | SO_KEEPALIVE | This option specifies whether socket implementations can send keepalive messages if no data has been sent for a longer time. | |||||||||
int | SO_LINGER | This option specifies the behavior of the close() method if there
is still some buffered data to be sent while closing the socket. |
|||||||||
int | SO_OOBINLINE | This option specifies whether sending TCP urgent data is supported on this socket or not. | |||||||||
int | SO_RCVBUF | Buffer size of the incoming channel. | |||||||||
int | SO_REUSEADDR | This option specifies whether a reuse of a local address is allowed even if an other socket is not yet removed by the operating system. | |||||||||
int | SO_SNDBUF | Buffer size of the outgoing channel. | |||||||||
int | SO_TIMEOUT | Timeout for blocking accept or read/receive operations (but not write/send operations). | |||||||||
int | TCP_NODELAY | This option specifies whether data is sent immediately on this socket, as a side-effect though, this could lead to a low packet efficiency. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the value for the specified socket option.
| |||||||||||
Sets the value of the specified socket option.
|
This option specifies the interface which is used to send multicast
packets. It's only available on a MulticastSocket
.
This option can be used to set one specific interface on a multihomed host on which incoming connections are accepted. It's only available on server-side sockets. This option supports setting outgoing interfaces with either IPv4 or IPv6 addresses.
This option specifies whether the local loopback of multicast packets is enabled or disabled. This option is enabled by default on multicast sockets.
This option specifies the value for the Type-of-Service (TOS) field of the IP header. This may be ignored by the underlying OS. Values must be between 0 and 255 inclusive. See RFC 1349 for more information.
This option can be used to set one specific interface on a multihomed host on which incoming connections are accepted. It's only available on server-side sockets.
This option can be used to enable broadcasting on datagram sockets.
This option specifies whether socket implementations can send keepalive messages if no data has been sent for a longer time.
This option specifies the behavior of the close()
method if there
is still some buffered data to be sent while closing the socket. If the
value of this option is set to 0
the method closes the TCP socket
forcefully and returns immediately. Is this value greater than 0
the method blocks this time in milliseconds. If all data could be sent
during this timeout the socket is closed normally otherwise forcefully.
Valid values for this option are in the range 0 <= SO_LINGER <=
65535
. (Larger timeouts will be treated as 65535s timeouts; roughly 18 hours.)
This option specifies whether sending TCP urgent data is supported on this socket or not.
Buffer size of the incoming channel.
This option specifies whether a reuse of a local address is allowed even
if an other socket is not yet removed by the operating system. It's only
available on a MulticastSocket
.
Buffer size of the outgoing channel.
Timeout for blocking accept or read/receive operations (but not write/send operations).
The argument value is specified in milliseconds, with 0 meaning no timeout and negative
values not allowed.
An InterruptedIOException
is thrown if this timeout expires.
This option specifies whether data is sent immediately on this socket, as a side-effect though, this could lead to a low packet efficiency. The socket implementation uses the Nagle's algorithm to try to reach a higher packet efficiency if this option is disabled.
Gets the value for the specified socket option.
optID | the option identifier. |
---|
SocketException | if an error occurs reading the option value. |
---|
Sets the value of the specified socket option.
optID | the option identifier. |
---|---|
val | the value to be set for the option. |
SocketException | if an error occurs setting the option value. |
---|