Frames | No Frames |
1: /* SocketOptions.java -- Implements options for sockets (duh!) 2: Copyright (C) 1998, 1999, 2000, 2001, 3: 2002, 2003 Free Software Foundation, Inc. 4: 5: This file is part of GNU Classpath. 6: 7: GNU Classpath is free software; you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation; either version 2, or (at your option) 10: any later version. 11: 12: GNU Classpath is distributed in the hope that it will be useful, but 13: WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15: General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with GNU Classpath; see the file COPYING. If not, write to the 19: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20: 02110-1301 USA. 21: 22: Linking this library statically or dynamically with other modules is 23: making a combined work based on this library. Thus, the terms and 24: conditions of the GNU General Public License cover the whole 25: combination. 26: 27: As a special exception, the copyright holders of this library give you 28: permission to link this library with independent modules to produce an 29: executable, regardless of the license terms of these independent 30: modules, and to copy and distribute the resulting executable under 31: terms of your choice, provided that you also meet, for each linked 32: independent module, the terms and conditions of the license of that 33: module. An independent module is a module which is not derived from 34: or based on this library. If you modify this library, you may extend 35: this exception to your version of the library, but you are not 36: obligated to do so. If you do not wish to do so, delete this 37: exception statement from your version. */ 38: 39: package java.net; 40: 41: 42: /** 43: * Written using on-line Java Platform 1.2 API Specification. 44: * Status: Believed complete and correct. 45: */ 46: /** 47: * This interface is used by <code>SocketImpl</code> and 48: * <code>DatagramSocketImpl</code> to implement options 49: * on sockets. 50: * 51: * @since 1.2 52: * 53: * @author Aaron M. Renn (arenn@urbanophile.com) 54: * @author Warren Levy (warrenl@cygnus.com) 55: * @status should be completely JDK 1.4 compatible 56: */ 57: public interface SocketOptions 58: { 59: /** 60: * Option id for the SO_KEEPALIVE value 61: * @since 1.3 62: */ 63: int SO_KEEPALIVE = 0x8; 64: 65: /** 66: * Option id for the SO_LINGER value 67: */ 68: int SO_LINGER = 0x80; // 128 69: 70: /** 71: * Option id for the SO_TIMEOUT value 72: */ 73: int SO_TIMEOUT = 0x1006; // 4102 74: 75: /** 76: * Retrieve the local address to which the socket is bound. 77: */ 78: int SO_BINDADDR = 0x0F; // 15 79: 80: /** 81: * Option id for the send buffer size 82: * @since 1.2 83: */ 84: int SO_SNDBUF = 0x1001; // 4097 85: 86: /** 87: * Option id for the receive buffer size 88: * @since 1.2 89: */ 90: int SO_RCVBUF = 0x1002; // 4098 91: 92: /** 93: * Sets the SO_REUSEADDR parameter on a socket 94: */ 95: int SO_REUSEADDR = 0x04; // 4 96: 97: /** 98: * Sets SO_BROADCAST for a socket 99: * @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