2003-11-26 Michael Koch <konqueror@gmx.de>
authorMichael Koch <konqueror@gmx.de>
Wed, 26 Nov 2003 14:50:27 +0000 (14:50 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Wed, 26 Nov 2003 14:50:27 +0000 (14:50 +0000)
* java/net/DatagramSocket.java
(DategramSocket, bind): Moved binding code from DatagramSocket
constructor to bind method.

From-SVN: r73952

libjava/ChangeLog
libjava/java/net/DatagramSocket.java

index 9d13b76945a2ff1021bd89906297cec792412422..570890540aeb008fb1daa40d2f74614d55a5ea0d 100644 (file)
@@ -1,3 +1,9 @@
+2003-11-26  Michael Koch  <konqueror@gmx.de>
+
+       * java/net/DatagramSocket.java
+       (DategramSocket, bind): Moved binding code from DatagramSocket
+       constructor to bind method.
+
 2003-11-26  Michael Koch  <konqueror@gmx.de>
 
        * java/net/DatagramSocket.java
index df397bf7c612ec962c00f7e5229997a31aefa535..f4bc4ea79d5eaced1261d01cc91c50bb0ffcf200 100644 (file)
@@ -187,44 +187,8 @@ public class DatagramSocket
          impl = new PlainDatagramSocketImpl();
        }
 
-    if (address == null)
-      return;
-
-    if (! (address instanceof InetSocketAddress))
-      throw new SocketException("unsupported address type");
-
-    InetAddress addr = ((InetSocketAddress) address).getAddress();
-    int port = ((InetSocketAddress) address).getPort();
-
-    if (port < 0 || port > 65535)
-      throw new IllegalArgumentException("Invalid port: " + port);
-
-    SecurityManager s = System.getSecurityManager();
-    if (s != null)
-      s.checkListen(port);
-
-    if (addr == null)
-      addr = InetAddress.ANY_IF;
-    
-    try
-      {
-        getImpl().bind(port, addr);
-      }
-    catch (SocketException exception)
-      {
-        getImpl().close();
-        throw exception;
-      }
-    catch (RuntimeException exception)
-      {
-        getImpl().close();
-        throw exception;
-      }
-    catch (Error error)
-      {
-        getImpl().close();
-        throw error;
-      }
+    if (address != null)
+      bind(address);
   }
   
   // This needs to be accessible from java.net.MulticastSocket
@@ -671,14 +635,39 @@ public class DatagramSocket
     if (! (address instanceof InetSocketAddress))
       throw new IllegalArgumentException("unsupported address type");
 
-    InetSocketAddress tmp = (InetSocketAddress) address;
+    InetAddress addr = ((InetSocketAddress) address).getAddress();
+    int port = ((InetSocketAddress) address).getPort();
+
+    if (port < 0 || port > 65535)
+      throw new IllegalArgumentException("Invalid port: " + port);
 
     SecurityManager s = System.getSecurityManager ();
     if (s != null)
-      s.checkListen(tmp.getPort ());
+      s.checkListen(port);
 
-    getImpl().bind (tmp.getPort (), tmp.getAddress ());
-    bound = true;
+    if (addr == null)
+      addr = InetAddress.ANY_IF;
+    
+    try
+      {
+        getImpl().bind(port, addr);
+       bound = true;
+      }
+    catch (SocketException exception)
+      {
+        getImpl().close();
+        throw exception;
+      }
+    catch (RuntimeException exception)
+      {
+        getImpl().close();
+        throw exception;
+      }
+    catch (Error error)
+      {
+        getImpl().close();
+        throw error;
+      }
   }
 
   /**