java.net
Interface SocketOptions

All Known Implementing Classes:
DatagramSocketImpl, SocketImpl

public interface SocketOptions

This interface is used by SocketImpl and DatagramSocketImpl to implement options on sockets.

Since:
1.2

Field Summary
static int IP_MULTICAST_IF
          Options id for the IP_MULTICAST_IF value
static int IP_MULTICAST_IF2
          same as above
static int IP_MULTICAST_LOOP
          This option enables or disables local loopback of multicast datagrams.
static int IP_TOS
          This option sets the type-of-service or traffic class field in the IP header for a TCP or UDP socket.
static int SO_BINDADDR
          Retrieve the local address to which the socket is bound.
static int SO_BROADCAST
          Sets SO_BROADCAST for a socket
static int SO_KEEPALIVE
          Option id for the SO_KEEPALIVE value
static int SO_LINGER
          Option id for the SO_LINGER value
static int SO_OOBINLINE
          Sets SO_OOBINLINE for a socket
static int SO_RCVBUF
          Option id for the receive buffer size
static int SO_REUSEADDR
          Sets the SO_REUSEADDR parameter on a socket
static int SO_SNDBUF
          Option id for the send buffer size
static int SO_TIMEOUT
          Option id for the SO_TIMEOUT value
static int TCP_NODELAY
          Option id for the TCP_NODELAY value
 
Method Summary
 Object getOption(int optionId)
          Returns the current setting of the specified option.
 void setOption(int optionId, Object val)
          Sets the specified option on a socket to the passed in object.
 

Field Detail

SO_KEEPALIVE

static final int SO_KEEPALIVE
Option id for the SO_KEEPALIVE value

Since:
1.3
See Also:
Constant Field Values

SO_LINGER

static final int SO_LINGER
Option id for the SO_LINGER value

See Also:
Constant Field Values

SO_TIMEOUT

static final int SO_TIMEOUT
Option id for the SO_TIMEOUT value

See Also:
Constant Field Values

SO_BINDADDR

static final int SO_BINDADDR
Retrieve the local address to which the socket is bound.

See Also:
Constant Field Values

SO_SNDBUF

static final int SO_SNDBUF
Option id for the send buffer size

Since:
1.2
See Also:
Constant Field Values

SO_RCVBUF

static final int SO_RCVBUF
Option id for the receive buffer size

Since:
1.2
See Also:
Constant Field Values

SO_REUSEADDR

static final int SO_REUSEADDR
Sets the SO_REUSEADDR parameter on a socket

See Also:
Constant Field Values

SO_BROADCAST

static final int SO_BROADCAST
Sets SO_BROADCAST for a socket

Since:
1.4
See Also:
Constant Field Values

SO_OOBINLINE

static final int SO_OOBINLINE
Sets SO_OOBINLINE for a socket

Since:
1.4
See Also:
Constant Field Values

TCP_NODELAY

static final int TCP_NODELAY
Option id for the TCP_NODELAY value

See Also:
Constant Field Values

IP_MULTICAST_IF

static final int IP_MULTICAST_IF
Options id for the IP_MULTICAST_IF value

See Also:
Constant Field Values

IP_MULTICAST_IF2

static final int IP_MULTICAST_IF2
same as above

Since:
1.4
See Also:
Constant Field Values

IP_MULTICAST_LOOP

static final int IP_MULTICAST_LOOP
This option enables or disables local loopback of multicast datagrams.

Since:
1.4
See Also:
Constant Field Values

IP_TOS

static final int IP_TOS
This option sets the type-of-service or traffic class field in the IP header for a TCP or UDP socket.

Since:
1.4
See Also:
Constant Field Values
Method Detail

setOption

void setOption(int optionId,
               Object val)
               throws SocketException
Sets the specified option on a socket to the passed in object. For options that take an integer argument, the passed in object is an Integer. For options that are set to on or off, the value passed will be a Boolean. The optionId parameter is one of the defined constants in this interface.

Parameters:
optionId - The identifier of the option
val - The value to set the option to
Throws:
SocketException - If an error occurs

getOption

Object getOption(int optionId)
                 throws SocketException
Returns the current setting of the specified option. The Object returned will be an Integer for options that have integer values. For options that are set to on or off, a Boolean will be returned. The optionId parameter is one of the defined constants in this interface.

Parameters:
optionId - The option identifier
Returns:
The current value of the option
Throws:
SocketException - If an error occurs