--- a/jdk/src/java.base/share/classes/java/net/MulticastSocket.java Tue Feb 23 09:49:04 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/net/MulticastSocket.java Tue Feb 23 17:41:00 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -98,7 +98,11 @@
* <p>
* When the socket is created the
* {@link DatagramSocket#setReuseAddress(boolean)} method is
- * called to enable the SO_REUSEADDR socket option.
+ * called to enable the SO_REUSEADDR socket option. When
+ * {@link StandardSocketOptions#SO_REUSEPORT SO_REUSEPORT} is
+ * supported then
+ * {@link DatagramSocketImpl#setOption(SocketOption, Object)}
+ * is called to enable the socket option.
*
* @exception IOException if an I/O exception occurs
* while creating the MulticastSocket
@@ -106,6 +110,7 @@
* {@code checkListen} method doesn't allow the operation.
* @see SecurityManager#checkListen
* @see java.net.DatagramSocket#setReuseAddress(boolean)
+ * @see java.net.DatagramSocketImpl#setOption(SocketOption, Object)
*/
public MulticastSocket() throws IOException {
this(new InetSocketAddress(0));
@@ -167,6 +172,11 @@
// Enable SO_REUSEADDR before binding
setReuseAddress(true);
+ // Enable SO_REUSEPORT if supported before binding
+ if (supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
+ this.setOption(StandardSocketOptions.SO_REUSEPORT, true);
+ }
+
if (bindaddr != null) {
try {
bind(bindaddr);