SocketOptions.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* SocketOptions.java -- Implements options for sockets (duh!)
  2. Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.net;
  32. /**
  33. * Written using on-line Java Platform 1.2 API Specification.
  34. * Status: Believed complete and correct.
  35. */
  36. /**
  37. * This interface is used by <code>SocketImpl</code> and
  38. * <code>DatagramSocketImpl</code> to implement options
  39. * on sockets.
  40. *
  41. * @since 1.2
  42. *
  43. * @author Aaron M. Renn (arenn@urbanophile.com)
  44. * @author Warren Levy <warrenl@cygnus.com>
  45. * @status should be completely JDK 1.4 compatible
  46. */
  47. public interface SocketOptions
  48. {
  49. /**
  50. * Option id for the SO_KEEPALIVE value
  51. * @since 1.3
  52. */
  53. static final int SO_KEEPALIVE = 0x8;
  54. /**
  55. * Option id for the SO_LINGER value
  56. */
  57. static final int SO_LINGER = 0x80; // 128
  58. /**
  59. * Option id for the SO_TIMEOUT value
  60. */
  61. static final int SO_TIMEOUT = 0x1006; // 4102
  62. /**
  63. * Retrieve the local address to which the socket is bound.
  64. */
  65. static final int SO_BINDADDR = 0x0F; // 15
  66. /**
  67. * Option id for the send buffer size
  68. * @since 1.2
  69. */
  70. static final int SO_SNDBUF = 0x1001; // 4097
  71. /**
  72. * Option id for the receive buffer size
  73. * @since 1.2
  74. */
  75. static final int SO_RCVBUF = 0x1002; // 4098
  76. /**
  77. * Sets the SO_REUSEADDR parameter on a socket
  78. */
  79. static final int SO_REUSEADDR = 0x04; // 4
  80. /**
  81. * Sets SO_BROADCAST for a socket
  82. * @since 1.4
  83. */
  84. static final int SO_BROADCAST = 0x20; // 32
  85. /**
  86. * Sets SO_OOBINLINE for a socket
  87. * @since 1.4
  88. */
  89. static final int SO_OOBINLINE = 0x1003; // 4099
  90. /**
  91. * Option id for the TCP_NODELAY value
  92. */
  93. static final int TCP_NODELAY = 0x01; // 1
  94. /**
  95. * Options id for the IP_MULTICAST_IF value
  96. */
  97. static final int IP_MULTICAST_IF = 0x10; // 16
  98. /**
  99. * same as above
  100. * @since 1.4
  101. */
  102. static final int IP_MULTICAST_IF2 = 0x1F; // 31
  103. /**
  104. * This option enables or disables local loopback of multicast datagrams.
  105. * @since 1.4
  106. */
  107. static final int IP_MULTICAST_LOOP = 0x12; // 18
  108. /**
  109. * This option sets the type-of-service or traffic class field in the
  110. * IP header for a TCP or UDP socket.
  111. * @since 1.4
  112. */
  113. static final int IP_TOS = 0x03; // 3
  114. /**
  115. * Sets the specified option on a socket to the passed in object. For
  116. * options that take an integer argument, the passed in object is an
  117. * <code>Integer</code>. For options that are set to on or off, the
  118. * value passed will be a <code>Boolean</code>. The <code>option_id</code>
  119. * parameter is one of the defined constants in this interface.
  120. *
  121. * @param option_id The identifier of the option
  122. * @param val The value to set the option to
  123. *
  124. * @exception SocketException If an error occurs
  125. */
  126. void setOption(int option_id, Object val) throws SocketException;
  127. /**
  128. * Returns the current setting of the specified option. The
  129. * <code>Object</code> returned will be an <code>Integer</code> for options
  130. * that have integer values. For options that are set to on or off, a
  131. * <code>Boolean</code> will be returned. The <code>option_id</code>
  132. * is one of the defined constants in this interface.
  133. *
  134. * @param option_id The option identifier
  135. *
  136. * @return The current value of the option
  137. *
  138. * @exception SocketException If an error occurs
  139. */
  140. Object getOption(int option_id) throws SocketException;
  141. } // interface SocketOptions