235 Class<?> type = name.type(); |
235 Class<?> type = name.type(); |
236 if (type != Integer.class && type != Boolean.class) |
236 if (type != Integer.class && type != Boolean.class) |
237 throw new AssertionError("Should not reach here"); |
237 throw new AssertionError("Should not reach here"); |
238 |
238 |
239 // special handling |
239 // special handling |
240 if (name == StandardSocketOption.SO_RCVBUF || |
240 if (name == StandardSocketOptions.SO_RCVBUF || |
241 name == StandardSocketOption.SO_SNDBUF) |
241 name == StandardSocketOptions.SO_SNDBUF) |
242 { |
242 { |
243 int i = ((Integer)value).intValue(); |
243 int i = ((Integer)value).intValue(); |
244 if (i < 0) |
244 if (i < 0) |
245 throw new IllegalArgumentException("Invalid send/receive buffer size"); |
245 throw new IllegalArgumentException("Invalid send/receive buffer size"); |
246 } |
246 } |
247 if (name == StandardSocketOption.SO_LINGER) { |
247 if (name == StandardSocketOptions.SO_LINGER) { |
248 int i = ((Integer)value).intValue(); |
248 int i = ((Integer)value).intValue(); |
249 if (i < 0) |
249 if (i < 0) |
250 value = Integer.valueOf(-1); |
250 value = Integer.valueOf(-1); |
251 if (i > 65535) |
251 if (i > 65535) |
252 value = Integer.valueOf(65535); |
252 value = Integer.valueOf(65535); |
253 } |
253 } |
254 if (name == StandardSocketOption.IP_TOS) { |
254 if (name == StandardSocketOptions.IP_TOS) { |
255 int i = ((Integer)value).intValue(); |
255 int i = ((Integer)value).intValue(); |
256 if (i < 0 || i > 255) |
256 if (i < 0 || i > 255) |
257 throw new IllegalArgumentException("Invalid IP_TOS value"); |
257 throw new IllegalArgumentException("Invalid IP_TOS value"); |
258 } |
258 } |
259 if (name == StandardSocketOption.IP_MULTICAST_TTL) { |
259 if (name == StandardSocketOptions.IP_MULTICAST_TTL) { |
260 int i = ((Integer)value).intValue(); |
260 int i = ((Integer)value).intValue(); |
261 if (i < 0 || i > 255) |
261 if (i < 0 || i > 255) |
262 throw new IllegalArgumentException("Invalid TTL/hop value"); |
262 throw new IllegalArgumentException("Invalid TTL/hop value"); |
263 } |
263 } |
264 |
264 |