java.net

Interface SocketOptions

public interface SocketOptions

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

Since: 1.2

UNKNOWN: should be completely JDK 1.4 compatible

Field Summary
intIP_MULTICAST_IF
Options id for the IP_MULTICAST_IF value
intIP_MULTICAST_IF2
same as above
intIP_MULTICAST_LOOP
This option enables or disables local loopback of multicast datagrams.
intIP_TOS
This option sets the type-of-service or traffic class field in the IP header for a TCP or UDP socket.
intSO_BINDADDR
Retrieve the local address to which the socket is bound.
intSO_BROADCAST
Sets SO_BROADCAST for a socket
intSO_KEEPALIVE
Option id for the SO_KEEPALIVE value
intSO_LINGER
Option id for the SO_LINGER value
intSO_OOBINLINE
Sets SO_OOBINLINE for a socket
intSO_RCVBUF
Option id for the receive buffer size
intSO_REUSEADDR
Sets the SO_REUSEADDR parameter on a socket
intSO_SNDBUF
Option id for the send buffer size
intSO_TIMEOUT
Option id for the SO_TIMEOUT value
intTCP_NODELAY
Option id for the TCP_NODELAY value
Method Summary
ObjectgetOption(int optionId)
Returns the current setting of the specified option.
voidsetOption(int optionId, Object val)
Sets the specified option on a socket to the passed in object.

Field Detail

IP_MULTICAST_IF

public int IP_MULTICAST_IF
Options id for the IP_MULTICAST_IF value

IP_MULTICAST_IF2

public int IP_MULTICAST_IF2
same as above

Since: 1.4

IP_MULTICAST_LOOP

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

Since: 1.4

IP_TOS

public 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

SO_BINDADDR

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

SO_BROADCAST

public int SO_BROADCAST
Sets SO_BROADCAST for a socket

Since: 1.4

SO_KEEPALIVE

public int SO_KEEPALIVE
Option id for the SO_KEEPALIVE value

Since: 1.3

SO_LINGER

public int SO_LINGER
Option id for the SO_LINGER value

SO_OOBINLINE

public int SO_OOBINLINE
Sets SO_OOBINLINE for a socket

Since: 1.4

SO_RCVBUF

public int SO_RCVBUF
Option id for the receive buffer size

Since: 1.2

SO_REUSEADDR

public int SO_REUSEADDR
Sets the SO_REUSEADDR parameter on a socket

SO_SNDBUF

public int SO_SNDBUF
Option id for the send buffer size

Since: 1.2

SO_TIMEOUT

public int SO_TIMEOUT
Option id for the SO_TIMEOUT value

TCP_NODELAY

public int TCP_NODELAY
Option id for the TCP_NODELAY value

Method Detail

getOption

public Object getOption(int optionId)
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

setOption

public void setOption(int optionId, Object val)
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