1 |
/* SocketOptions.java -- Implements options for sockets (duh!) |
/* SocketOptions.java -- Implements options for sockets (duh!) |
2 |
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
43 |
*/ |
*/ |
44 |
|
|
45 |
/** |
/** |
46 |
* This interface is used by <code>SocketImpl</code> and |
* This interface is used by <code>SocketImpl</code> and |
47 |
* <code>DatagramSocketImpl</code> to implement options |
* <code>DatagramSocketImpl</code> to implement options |
48 |
* on sockets. |
* on sockets. |
49 |
* |
* |
50 |
* @since 1.2 |
* @since 1.2 |
51 |
* |
* |
52 |
* @author Aaron M. Renn (arenn@urbanophile.com) |
* @author Aaron M. Renn (arenn@urbanophile.com) |
53 |
* @author Warren Levy <warrenl@cygnus.com> |
* @author Warren Levy <warrenl@cygnus.com> |
54 |
*/ |
* @status should be completely JDK 1.4 compatible |
55 |
|
*/ |
56 |
public interface SocketOptions |
public interface SocketOptions |
57 |
{ |
{ |
58 |
|
/** |
59 |
/*************************************************************************/ |
* Option id for the SO_KEEPALIVE value |
60 |
|
* @since 1.3 |
61 |
/* |
*/ |
62 |
* Static Variables |
static final int SO_KEEPALIVE = 0x8; |
63 |
*/ |
|
64 |
|
/** |
65 |
/** |
* Option id for the SO_LINGER value |
66 |
* Option id for the SO_LINGER value |
*/ |
67 |
*/ |
static final int SO_LINGER = 0x80; // 128 |
68 |
static final int SO_LINGER = 0x80; // 128 |
|
69 |
|
/** |
70 |
/** |
* Option id for the SO_TIMEOUT value |
71 |
* Option id for the SO_TIMEOUT value |
*/ |
72 |
*/ |
static final int SO_TIMEOUT = 0x1006; // 4102 |
73 |
static final int SO_TIMEOUT = 0x1006; // 4102 |
|
74 |
|
/** |
75 |
/** |
* Retrieve the local address to which the socket is bound. |
76 |
* Retrieve the local address to which the socket is bound. |
*/ |
77 |
*/ |
static final int SO_BINDADDR = 0x0F; // 15 |
78 |
static final int SO_BINDADDR = 0x0F; // 15 |
|
79 |
|
/** |
80 |
/** |
* Option id for the send buffer size |
81 |
* Option id for the send buffer size |
* @since 1.2 |
82 |
* @since 1.2 |
*/ |
83 |
*/ |
static final int SO_SNDBUF = 0x1001; // 4097 |
84 |
static final int SO_SNDBUF = 0x1001; // 4097 |
|
85 |
|
/** |
86 |
/** |
* Option id for the receive buffer size |
87 |
* Option id for the receive buffer size |
* @since 1.2 |
88 |
* @since 1.2 |
*/ |
89 |
*/ |
static final int SO_RCVBUF = 0x1002; // 4098 |
90 |
static final int SO_RCVBUF = 0x1002; // 4098 |
|
91 |
|
/** |
92 |
/** |
* Sets the SO_REUSEADDR parameter on a socket |
93 |
* Sets the SO_REUSEADDR parameter on a socket |
*/ |
94 |
*/ |
static final int SO_REUSEADDR = 0x04; // 4 |
95 |
static final int SO_REUSEADDR = 0x04; // 4 |
|
96 |
|
/** |
97 |
/** |
* Sets SO_BROADCAST for a socket |
98 |
* Option id for the TCP_NODELAY value |
* @since 1.4 |
99 |
*/ |
*/ |
100 |
static final int TCP_NODELAY = 0x01; // 1 |
static final int SO_BROADCAST = 0x20; // 32 |
101 |
|
|
102 |
/** |
/** |
103 |
* Options id for the IP_MULTICAST_IF value |
* Sets SO_OOBINLINE for a socket |
104 |
*/ |
* @since 1.4 |
105 |
static final int IP_MULTICAST_IF = 0x10; // 16 |
*/ |
106 |
|
static final int SO_OOBINLINE = 0x1003; // 4099 |
107 |
/*************************************************************************/ |
|
108 |
|
/** |
109 |
/* |
* Option id for the TCP_NODELAY value |
110 |
* Interface Methods |
*/ |
111 |
*/ |
static final int TCP_NODELAY = 0x01; // 1 |
112 |
|
|
113 |
/** |
/** |
114 |
* Sets the specified option on a socket to the passed in object. For |
* Options id for the IP_MULTICAST_IF value |
115 |
* options that take an integer argument, the passed in object is an |
*/ |
116 |
* <code>Integer</code>. For options that are set to on or off, the |
static final int IP_MULTICAST_IF = 0x10; // 16 |
117 |
* value passed will be a <code>Boolean</code>. The <code>option_id</code> |
|
118 |
* parameter is one of the defined constants in this interface. |
/** |
119 |
* |
* same as above |
120 |
* @param option_id The identifier of the option |
* @since 1.4 |
121 |
* @param val The value to set the option to |
*/ |
122 |
* |
static final int IP_MULTICAST_IF2 = 0x1F; // 31 |
123 |
* @exception SocketException If an error occurs |
|
124 |
*/ |
/** |
125 |
void |
* This option enables or disables local loopback of multicast datagrams. |
126 |
setOption(int option_id, Object val) throws SocketException; |
* @since 1.4 |
127 |
|
*/ |
128 |
/*************************************************************************/ |
static final int IP_MULTICAST_LOOP = 0x12; // 18 |
129 |
|
|
130 |
/** |
/** |
131 |
* Returns the current setting of the specified option. The |
* This option sets the type-of-service or traffic class field in the |
132 |
* <code>Object</code> returned will be an <code>Integer</code> for options |
* IP header for a TCP or UDP socket. |
133 |
* that have integer values. For options that are set to on or off, a |
* @since 1.4 |
134 |
* <code>Boolean</code> will be returned. The <code>option_id</code> |
*/ |
135 |
* is one of the defined constants in this interface. |
static final int IP_TOS = 0x03; // 3 |
136 |
* |
|
137 |
* @param option_id The option identifier |
/** |
138 |
* |
* Sets the specified option on a socket to the passed in object. For |
139 |
* @return The current value of the option |
* options that take an integer argument, the passed in object is an |
140 |
* |
* <code>Integer</code>. For options that are set to on or off, the |
141 |
* @exception SocketException If an error occurs |
* value passed will be a <code>Boolean</code>. The <code>option_id</code> |
142 |
*/ |
* parameter is one of the defined constants in this interface. |
143 |
Object |
* |
144 |
getOption(int option_id) throws SocketException; |
* @param option_id The identifier of the option |
145 |
|
* @param val The value to set the option to |
146 |
|
* |
147 |
|
* @exception SocketException If an error occurs |
148 |
|
*/ |
149 |
|
void setOption(int option_id, Object val) throws SocketException; |
150 |
|
|
151 |
|
/** |
152 |
|
* Returns the current setting of the specified option. The |
153 |
|
* <code>Object</code> returned will be an <code>Integer</code> for options |
154 |
|
* that have integer values. For options that are set to on or off, a |
155 |
|
* <code>Boolean</code> will be returned. The <code>option_id</code> |
156 |
|
* is one of the defined constants in this interface. |
157 |
|
* |
158 |
|
* @param option_id The option identifier |
159 |
|
* |
160 |
|
* @return The current value of the option |
161 |
|
* |
162 |
|
* @exception SocketException If an error occurs |
163 |
|
*/ |
164 |
|
Object getOption(int option_id) throws SocketException; |
165 |
|
|
166 |
} // interface SocketOptions |
} // interface SocketOptions |
167 |
|
|