DthingApi
Public Member Functions | Static Public Attributes | List of all members
java.net.SocketOptions Interface Reference
Inheritance diagram for java.net.SocketOptions:
java.net.DatagramSocketImpl java.net.SocketImpl java.net.PlainDatagramSocketImpl java.net.PlainSocketImpl

Public Member Functions

Object getOption (int optID) throws SocketException
 
void setOption (int optID, int val) throws SocketException
 

Static Public Attributes

static final int SO_LINGER = 128
 
static final int SO_TIMEOUT = 4102
 
static final int TCP_NODELAY = 1
 
static final int IP_MULTICAST_IF = 16
 
static final int SO_BINDADDR = 15
 
static final int SO_REUSEADDR = 4
 
static final int SO_SNDBUF = 4097
 
static final int SO_RCVBUF = 4098
 
static final int SO_KEEPALIVE = 8
 
static final int IP_TOS = 3
 
static final int IP_MULTICAST_LOOP = 18
 
static final int SO_BROADCAST = 32
 
static final int SO_OOBINLINE = 4099
 
static final int IP_MULTICAST_IF2 = 31
 

Detailed Description

Defines an interface for socket implementations to get and set socket options. It is implemented by the classes

SocketImpl

and

DatagramSocketImpl

.

See also
SocketImpl
DatagramSocketImpl

Member Function Documentation

◆ getOption()

Object java.net.SocketOptions.getOption ( int  optID) throws SocketException

Gets the value for the specified socket option.

Returns
the option value.
Parameters
optIDthe option identifier.
Exceptions
SocketExceptionif an error occurs reading the option value.

Implemented in java.net.PlainSocketImpl, and java.net.PlainDatagramSocketImpl.

◆ setOption()

void java.net.SocketOptions.setOption ( int  optID,
int  val 
) throws SocketException

Sets the value of the specified socket option.

Parameters
optIDthe option identifier.
valthe value to be set for the option.
Exceptions
SocketExceptionif an error occurs setting the option value.

Implemented in java.net.PlainSocketImpl, and java.net.PlainDatagramSocketImpl.

Member Data Documentation

◆ IP_MULTICAST_IF

final int java.net.SocketOptions.IP_MULTICAST_IF = 16
static

This is an IPv4-only socket option whose functionality is subsumed by IP_MULTICAST_IF and not implemented on Android.

◆ IP_MULTICAST_IF2

final int java.net.SocketOptions.IP_MULTICAST_IF2 = 31
static

This integer option sets the outgoing interface for multicast packets using an interface index.

◆ IP_MULTICAST_LOOP

final int java.net.SocketOptions.IP_MULTICAST_LOOP = 18
static

This boolean option specifies whether the local loopback of multicast packets is enabled or disabled. This option is enabled by default on multicast sockets. Note that the sense of this option in Java is the opposite of the underlying Unix

. See MulticastSocket#setLoopbackMode.

◆ IP_TOS

final int java.net.SocketOptions.IP_TOS = 3
static

This integer option specifies the value for the type-of-service field of the IPv4 header, or the traffic class field of the IPv6 header. These correspond to the IP_TOS and IPV6_TCLASS socket options. These may be ignored by the underlying OS. Values must be between 0 and 255 inclusive.

See RFC 1349 for more about IPv4 and RFC 2460 for more about IPv6.

◆ SO_BINDADDR

final int java.net.SocketOptions.SO_BINDADDR = 15
static

This option does not correspond to any Unix socket option and is not implemented on Android.

◆ SO_BROADCAST

final int java.net.SocketOptions.SO_BROADCAST = 32
static

This boolean option can be used to enable broadcasting on datagram sockets.

◆ SO_KEEPALIVE

final int java.net.SocketOptions.SO_KEEPALIVE = 8
static

This boolean option specifies whether the kernel sends keepalive messages.

◆ SO_LINGER

final int java.net.SocketOptions.SO_LINGER = 128
static

Number of seconds to wait when closing a socket if there is still some buffered data to be sent.

If this option is set to 0, the TCP socket is closed forcefully and the call to

close

returns immediately.

If this option is set to a value greater than 0, the value is interpreted as the number of seconds to wait. If all data could be sent during this time, the socket is closed normally. Otherwise the connection will be closed forcefully.

Valid values for this option are in the range 0 to 65535 inclusive. (Larger timeouts will be treated as 65535s timeouts; roughly 18 hours.)

◆ SO_OOBINLINE

final int java.net.SocketOptions.SO_OOBINLINE = 4099
static

This boolean option specifies whether sending TCP urgent data is supported on this socket or not.

◆ SO_RCVBUF

final int java.net.SocketOptions.SO_RCVBUF = 4098
static

The size in bytes of a socket's receive buffer. This must be an integer greater than 0. This is a hint to the kernel; the kernel may use a larger buffer.

For datagram sockets, packets larger than this value will be discarded.

◆ SO_REUSEADDR

final int java.net.SocketOptions.SO_REUSEADDR = 4
static

This boolean option specifies whether a reuse of a local address is allowed even if another socket is not yet removed by the operating system. It's only available on a

MulticastSocket

.

◆ SO_SNDBUF

final int java.net.SocketOptions.SO_SNDBUF = 4097
static

The size in bytes of a socket's send buffer. This must be an integer greater than 0. This is a hint to the kernel; the kernel may use a larger buffer.

For datagram sockets, it is implementation-defined whether packets larger than this size can be sent.

◆ SO_TIMEOUT

final int java.net.SocketOptions.SO_TIMEOUT = 4102
static

Integer timeout in milliseconds for blocking accept or read/receive operations (but not write/send operations). A timeout of 0 means no timeout. Negative timeouts are not allowed.

An

InterruptedIOException

is thrown if this timeout expires.

◆ TCP_NODELAY

final int java.net.SocketOptions.TCP_NODELAY = 1
static

This boolean option specifies whether data is sent immediately on this socket. As a side-effect this could lead to low packet efficiency. The socket implementation uses the Nagle's algorithm to try to reach a higher packet efficiency if this option is disabled.


The documentation for this interface was generated from the following file: