equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. 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. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
43 init(); |
43 init(); |
44 } |
44 } |
45 |
45 |
46 protected <T> void setOption(SocketOption<T> name, T value) throws IOException { |
46 protected <T> void setOption(SocketOption<T> name, T value) throws IOException { |
47 if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { |
47 if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { |
48 super.setOption(name, value); |
48 if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) { |
|
49 super.setOption(name, value); |
|
50 } else { |
|
51 if (supportedOptions().contains(name)) { |
|
52 super.setOption(name, value); |
|
53 } else { |
|
54 throw new UnsupportedOperationException("unsupported option"); |
|
55 } |
|
56 } |
49 } else { |
57 } else { |
50 if (!flowSupported()) { |
58 if (!flowSupported()) { |
51 throw new UnsupportedOperationException("unsupported option"); |
59 throw new UnsupportedOperationException("unsupported option"); |
52 } |
60 } |
53 if (isClosed()) { |
61 if (isClosed()) { |
60 } |
68 } |
61 |
69 |
62 @SuppressWarnings("unchecked") |
70 @SuppressWarnings("unchecked") |
63 protected <T> T getOption(SocketOption<T> name) throws IOException { |
71 protected <T> T getOption(SocketOption<T> name) throws IOException { |
64 if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { |
72 if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { |
65 return super.getOption(name); |
73 if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) { |
|
74 return super.getOption(name); |
|
75 } else { |
|
76 if (supportedOptions().contains(name)) { |
|
77 return super.getOption(name); |
|
78 } else { |
|
79 throw new UnsupportedOperationException("unsupported option"); |
|
80 } |
|
81 } |
66 } |
82 } |
67 if (!flowSupported()) { |
83 if (!flowSupported()) { |
68 throw new UnsupportedOperationException("unsupported option"); |
84 throw new UnsupportedOperationException("unsupported option"); |
69 } |
85 } |
70 if (isClosed()) { |
86 if (isClosed()) { |
85 } |
101 } |
86 return options; |
102 return options; |
87 } |
103 } |
88 |
104 |
89 protected void socketSetOption(int opt, Object val) throws SocketException { |
105 protected void socketSetOption(int opt, Object val) throws SocketException { |
|
106 if (opt == SocketOptions.SO_REUSEPORT && !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) { |
|
107 throw new UnsupportedOperationException("unsupported option"); |
|
108 } |
90 try { |
109 try { |
91 socketSetOption0(opt, val); |
110 socketSetOption0(opt, val); |
92 } catch (SocketException se) { |
111 } catch (SocketException se) { |
93 if (!connected) |
112 if (!connected) |
94 throw se; |
113 throw se; |