java.net

Interface SocketOptions

Known Implementing Classes:
DatagramSocketImpl, NIOSocketImpl, PlainDatagramSocketImpl, PlainSocketImpl, 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 Details

IP_MULTICAST_IF

public static final int IP_MULTICAST_IF
Options id for the IP_MULTICAST_IF value
Field Value:
16

IP_MULTICAST_IF2

public static final int IP_MULTICAST_IF2
same as above
Field Value:
31
Since:
1.4

IP_MULTICAST_LOOP

public static final int IP_MULTICAST_LOOP
This option enables or disables local loopback of multicast datagrams.
Field Value:
18
Since:
1.4

IP_TOS

public 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.
Field Value:
3
Since:
1.4

SO_BINDADDR

public static final int SO_BINDADDR
Retrieve the local address to which the socket is bound.
Field Value:
15

SO_BROADCAST

public static final int SO_BROADCAST
Sets SO_BROADCAST for a socket
Field Value:
32
Since:
1.4

SO_KEEPALIVE

public static final int SO_KEEPALIVE
Option id for the SO_KEEPALIVE value
Field Value:
8
Since:
1.3

SO_LINGER

public static final int SO_LINGER
Option id for the SO_LINGER value
Field Value:
128

SO_OOBINLINE

public static final int SO_OOBINLINE
Sets SO_OOBINLINE for a socket
Field Value:
4099
Since:
1.4

SO_RCVBUF

public static final int SO_RCVBUF
Option id for the receive buffer size
Field Value:
4098
Since:
1.2

SO_REUSEADDR

public static final int SO_REUSEADDR
Sets the SO_REUSEADDR parameter on a socket
Field Value:
4

SO_SNDBUF

public static final int SO_SNDBUF
Option id for the send buffer size
Field Value:
4097
Since:
1.2

SO_TIMEOUT

public static final int SO_TIMEOUT
Option id for the SO_TIMEOUT value
Field Value:
4102

TCP_NODELAY

public static final int TCP_NODELAY
Option id for the TCP_NODELAY value
Field Value:
1

Method Details

getOption

public 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

setOption

public 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

SocketOptions.java -- Implements options for sockets (duh!) Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.