mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8233296: MulticastSocket getOption/setOption inverts the value of IP_MULTICAST_LOOP
MulticastSocket.getOption(StandardSocketOption.IP_MULTICAST_LOOP) now returns true if loopback mode is enabled, and MulticastSocket.setOption(StandardSocketOption.IP_MULTICAST_LOOP, true) enables loopback mode. No other behavioral changes. Reviewed-by: alanb, chegar
This commit is contained in:
parent
0a1737ca97
commit
8333ea85fa
3 changed files with 321 additions and 4 deletions
|
@ -482,7 +482,9 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
throw new IllegalArgumentException("Invalid TTL/hop value: " + value);
|
||||
setTimeToLive((Integer)value);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_LOOP) {
|
||||
setOption(SocketOptions.IP_MULTICAST_LOOP, value);
|
||||
boolean enable = (boolean) value;
|
||||
// Legacy setOption expects true to mean 'disabled'
|
||||
setOption(SocketOptions.IP_MULTICAST_LOOP, !enable);
|
||||
} else if (extendedOptions.isOptionSupported(name)) {
|
||||
extendedOptions.setOption(fd, name, value);
|
||||
} else {
|
||||
|
@ -517,7 +519,9 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
} else if (name == StandardSocketOptions.IP_MULTICAST_TTL) {
|
||||
return (T) ((Integer) getTimeToLive());
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_LOOP) {
|
||||
return (T) getOption(SocketOptions.IP_MULTICAST_LOOP);
|
||||
boolean disabled = (boolean) getOption(SocketOptions.IP_MULTICAST_LOOP);
|
||||
// Legacy getOption returns true when disabled
|
||||
return (T) Boolean.valueOf(!disabled);
|
||||
} else if (extendedOptions.isOptionSupported(name)) {
|
||||
return (T) extendedOptions.getOption(fd, name);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue