equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
46 |
46 |
47 public static void main(String[] args) throws IOException { |
47 public static void main(String[] args) throws IOException { |
48 SocketChannel sc = SocketChannel.open(); |
48 SocketChannel sc = SocketChannel.open(); |
49 |
49 |
50 // check supported options |
50 // check supported options |
51 Set<SocketOption<?>> options = sc.options(); |
51 Set<SocketOption<?>> options = sc.supportedOptions(); |
52 List<? extends SocketOption> expected = Arrays.asList(SO_SNDBUF, SO_RCVBUF, |
52 List<? extends SocketOption> expected = Arrays.asList(SO_SNDBUF, SO_RCVBUF, |
53 SO_KEEPALIVE, SO_REUSEADDR, SO_LINGER, TCP_NODELAY); |
53 SO_KEEPALIVE, SO_REUSEADDR, SO_LINGER, TCP_NODELAY); |
54 for (SocketOption opt: expected) { |
54 for (SocketOption opt: expected) { |
55 if (!options.contains(opt)) |
55 if (!options.contains(opt)) |
56 throw new RuntimeException(opt.name() + " should be supported"); |
56 throw new RuntimeException(opt.name() + " should be supported"); |