equal
deleted
inserted
replaced
92 private DatagramSocket socket; |
92 private DatagramSocket socket; |
93 |
93 |
94 // Multicast support |
94 // Multicast support |
95 private MembershipRegistry registry; |
95 private MembershipRegistry registry; |
96 |
96 |
|
97 // set true when socket is bound and SO_REUSEADDRESS is emulated |
|
98 private boolean reuseAddressEmulated; |
|
99 |
|
100 // set true/false when socket is already bound and SO_REUSEADDR is emulated |
|
101 private boolean isReuseAddress; |
|
102 |
97 // -- End of fields protected by stateLock |
103 // -- End of fields protected by stateLock |
98 |
104 |
99 |
105 |
100 public DatagramChannelImpl(SelectorProvider sp) |
106 public DatagramChannelImpl(SelectorProvider sp) |
101 throws IOException |
107 throws IOException |
220 int targetAddress = Net.inet4AsInt(target); |
226 int targetAddress = Net.inet4AsInt(target); |
221 Net.setInterface4(fd, targetAddress); |
227 Net.setInterface4(fd, targetAddress); |
222 } |
228 } |
223 return this; |
229 return this; |
224 } |
230 } |
|
231 if (name == StandardSocketOptions.SO_REUSEADDR && |
|
232 Net.useExclusiveBind() && localAddress != null) |
|
233 { |
|
234 reuseAddressEmulated = true; |
|
235 this.isReuseAddress = (Boolean)value; |
|
236 } |
225 |
237 |
226 // remaining options don't need any special handling |
238 // remaining options don't need any special handling |
227 Net.setSocketOption(fd, Net.UNSPEC, name, value); |
239 Net.setSocketOption(fd, Net.UNSPEC, name, value); |
228 return this; |
240 return this; |
229 } |
241 } |
276 NetworkInterface ni = NetworkInterface.getByIndex(index); |
288 NetworkInterface ni = NetworkInterface.getByIndex(index); |
277 if (ni == null) |
289 if (ni == null) |
278 throw new IOException("Unable to map index to interface"); |
290 throw new IOException("Unable to map index to interface"); |
279 return (T) ni; |
291 return (T) ni; |
280 } |
292 } |
|
293 } |
|
294 |
|
295 if (name == StandardSocketOptions.SO_REUSEADDR && |
|
296 reuseAddressEmulated) |
|
297 { |
|
298 return (T)Boolean.valueOf(isReuseAddress); |
281 } |
299 } |
282 |
300 |
283 // no special handling |
301 // no special handling |
284 return (T) Net.getSocketOption(fd, Net.UNSPEC, name); |
302 return (T) Net.getSocketOption(fd, Net.UNSPEC, name); |
285 } |
303 } |