001/* SocketOptions.java -- Implements options for sockets (duh!)
002   Copyright (C) 1998, 1999, 2000, 2001,
003                 2002, 2003 Free Software Foundation, Inc.
004
005This file is part of GNU Classpath.
006
007GNU Classpath is free software; you can redistribute it and/or modify
008it under the terms of the GNU General Public License as published by
009the Free Software Foundation; either version 2, or (at your option)
010any later version.
011
012GNU Classpath is distributed in the hope that it will be useful, but
013WITHOUT ANY WARRANTY; without even the implied warranty of
014MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015General Public License for more details.
016
017You should have received a copy of the GNU General Public License
018along with GNU Classpath; see the file COPYING.  If not, write to the
019Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02002110-1301 USA.
021
022Linking this library statically or dynamically with other modules is
023making a combined work based on this library.  Thus, the terms and
024conditions of the GNU General Public License cover the whole
025combination.
026
027As a special exception, the copyright holders of this library give you
028permission to link this library with independent modules to produce an
029executable, regardless of the license terms of these independent
030modules, and to copy and distribute the resulting executable under
031terms of your choice, provided that you also meet, for each linked
032independent module, the terms and conditions of the license of that
033module.  An independent module is a module which is not derived from
034or based on this library.  If you modify this library, you may extend
035this exception to your version of the library, but you are not
036obligated to do so.  If you do not wish to do so, delete this
037exception statement from your version. */
038
039package java.net;
040
041
042/**
043 * Written using on-line Java Platform 1.2 API Specification.
044 * Status:  Believed complete and correct.
045 */
046/**
047 * This interface is used by <code>SocketImpl</code> and
048 * <code>DatagramSocketImpl</code> to implement options
049 * on sockets.
050 *
051 * @since 1.2
052 *
053 * @author Aaron M. Renn (arenn@urbanophile.com)
054 * @author Warren Levy (warrenl@cygnus.com)
055 * @status should be completely JDK 1.4 compatible
056 */
057public interface SocketOptions
058{
059  /**
060   * Option id for the SO_KEEPALIVE value
061   * @since 1.3
062   */
063  int SO_KEEPALIVE = 0x8;
064
065  /**
066   * Option id for the SO_LINGER value
067   */
068  int SO_LINGER = 0x80; // 128
069
070  /**
071   * Option id for the SO_TIMEOUT value
072   */
073  int SO_TIMEOUT = 0x1006; // 4102
074
075  /**
076   * Retrieve the local address to which the socket is bound.
077   */
078  int SO_BINDADDR = 0x0F; // 15
079
080  /**
081   * Option id for the send buffer size
082   * @since 1.2
083   */
084  int SO_SNDBUF = 0x1001; // 4097
085
086  /**
087   * Option id for the receive buffer size
088   * @since 1.2
089   */
090  int SO_RCVBUF = 0x1002; // 4098
091
092  /**
093   * Sets the SO_REUSEADDR parameter on a socket
094   */
095  int SO_REUSEADDR = 0x04; // 4
096
097  /**
098   * Sets SO_BROADCAST for a socket
099   * @since 1.4
100   */
101  int SO_BROADCAST = 0x20; // 32
102
103  /**
104   * Sets SO_OOBINLINE for a socket
105   * @since 1.4
106   */
107  int SO_OOBINLINE = 0x1003; // 4099
108
109  /**
110   * Option id for the TCP_NODELAY value
111   */
112  int TCP_NODELAY = 0x01; // 1
113
114  /**
115   * Options id for the IP_MULTICAST_IF value
116   */
117  int IP_MULTICAST_IF = 0x10; // 16
118
119  /**
120   * same as above
121   * @since 1.4
122   */
123  int IP_MULTICAST_IF2 = 0x1F; // 31
124
125  /**
126   * This option enables or disables local loopback of multicast datagrams.
127   * @since 1.4
128   */
129  int IP_MULTICAST_LOOP = 0x12; // 18
130
131  /**
132   * This option sets the type-of-service or traffic class field in the
133   * IP header for a TCP or UDP socket.
134   * @since 1.4
135   */
136  int IP_TOS = 0x03; // 3
137
138  /**
139   * Sets the specified option on a socket to the passed in object.  For
140   * options that take an integer argument, the passed in object is an
141   * <code>Integer</code>.  For options that are set to on or off, the
142   * value passed will be a <code>Boolean</code>.   The <code>optionId</code>
143   * parameter is one of the defined constants in this interface.
144   *
145   * @param optionId The identifier of the option
146   * @param val The value to set the option to
147   *
148   * @exception SocketException If an error occurs
149   */
150  void setOption(int optionId, Object val) throws SocketException;
151
152  /**
153   * Returns the current setting of the specified option.  The
154   * <code>Object</code> returned will be an <code>Integer</code> for options
155   * that have integer values.  For options that are set to on or off, a
156   * <code>Boolean</code> will be returned.   The <code>optionId</code>
157   * parameter is one of the defined constants in this interface.
158   *
159   * @param optionId The option identifier
160   *
161   * @return The current value of the option
162   *
163   * @exception SocketException If an error occurs
164   */
165  Object getOption(int optionId) throws SocketException;
166} // interface SocketOptions