[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] DatagramSocket bind (null) fix

From: Dalibor Topic
Subject: [PATCH] DatagramSocket bind (null) fix
Date: Fri, 21 Nov 2003 18:17:02 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312

Hi all,

attached is a small patch from Guilhem hat fixes the behaviour of DatagramSocket.bind(null) to match the API spec in 1.4.2, i.e. pick an ephemeral port and a local address to bind to.

2003-11-21  Guilhem Lavaux <address@hidden>

        * libraries/javalib/java/net/
        (bind) When address is null, it should bind to an available
--- /var/tmp/PROJECTS/classpath//./java/net/ Mon Sep 22 
16:56:08 2003
+++ /tmp/topic/kaffe/libraries/javalib/java/net/     Mon Nov 
 3 18:24:43 2003
@@ -573,7 +579,8 @@
    * Binds the socket to the given socket address.
-   * @param address The socket address to bind to.
+   * @param address The socket address to bind to. If address is null, bind
+   * will take an ephemeral port and a valid local address to bind the socket.
    * @exception SocketException If an error occurs.
    * @exception SecurityException If a security manager exists and
@@ -585,6 +592,9 @@
   public void bind (SocketAddress address)
     throws SocketException
+    if (address == null)
+      address = new InetSocketAddress (InetAddress.ANY_IF, 0);
     if (! (address instanceof InetSocketAddress))
       throw new IllegalArgumentException ();

reply via email to

[Prev in Thread] Current Thread [Next in Thread]