This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: java.net: ServerSocket and Socket.


Hi list,


I commited the attached patch to mainly make "isBound()" really working.



Michael
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2363
diff -u -b -B -r1.2363 ChangeLog
--- ChangeLog	26 Nov 2003 11:45:30 -0000	1.2363
+++ ChangeLog	26 Nov 2003 12:43:49 -0000
@@ -1,5 +1,22 @@
 2003-11-26  Michael Koch  <konqueror@gmx.de>
 
+	* java/net/Socket.java
+	(implCreated): Dont set default value explicitely, added
+	documentation.
+	(inputShutdown): Likewise.
+	(outputShutdown): Likewise.
+	(bound): New private member variable.
+	(bind): Set bound to true.
+	(close): Set bound to false.
+	(isBound): Return bound.
+	* java/net/ServerSocket.java
+	(bound): New private member variable.
+	(bind): Set bound to true.
+	(close): Set bound to false.
+	(isBound): Return bound.
+
+2003-11-26  Michael Koch  <konqueror@gmx.de>
+
 	* java/net/URL.java
 	(URL): Fixed documentation to be HTML compliant.
 	(getContent): Completed documentation.
Index: java/net/Socket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Socket.java,v
retrieving revision 1.30
diff -u -b -B -r1.30 Socket.java
--- java/net/Socket.java	25 Nov 2003 10:09:48 -0000	1.30
+++ java/net/Socket.java	26 Nov 2003 12:43:49 -0000
@@ -79,10 +79,25 @@
    */
   private SocketImpl impl;
 
-  private boolean implCreated = false;
+  /**
+   * True if socket implementation was created by calling their create() method.
+   */
+  private boolean implCreated;
+
+  /**
+   * True if the socket is bound.
+   */
+  private boolean bound;
 
-  private boolean inputShutdown = false;
-  private boolean outputShutdown = false;
+  /**
+   * True if input is shutdown.
+   */
+  private boolean inputShutdown;
+
+  /**
+   * True if output is shutdown.
+   */
+  private boolean outputShutdown;
 
   /**
    * Initializes a new instance of <code>Socket</code> object without 
@@ -342,6 +357,7 @@
     try
       {
         getImpl().bind (tmp.getAddress(), tmp.getPort());
+	bound = true;
       }
     catch (IOException exception)
       {
@@ -995,6 +1011,7 @@
       getChannel().close();
     
     impl = null;
+    bound = false;
   }
 
   /**
@@ -1206,7 +1223,7 @@
    */
   public boolean isBound ()
   {
-    return getLocalAddress () != null;
+    return bound;
   }
 
   /**
Index: java/net/ServerSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/ServerSocket.java,v
retrieving revision 1.29
diff -u -b -B -r1.29 ServerSocket.java
--- java/net/ServerSocket.java	25 Nov 2003 10:09:48 -0000	1.29
+++ java/net/ServerSocket.java	26 Nov 2003 12:43:49 -0000
@@ -73,6 +73,11 @@
    */
   private SocketImpl impl;
 
+  /**
+   * True if socket is bound.
+   */
+  private boolean bound;
+  
   /*
    * This constructor is only used by java.nio.
    */
@@ -225,6 +230,7 @@
       {
 	impl.bind (tmp.getAddress (), tmp.getPort ());
 	impl.listen(backlog);
+	bound = true;
       }
     catch (IOException exception)
       {
@@ -355,6 +361,7 @@
 	  getChannel().close();
     
 	impl = null;
+	bound = false;
       }
   }
 
@@ -379,16 +386,7 @@
    */
   public boolean isBound()
   {
-    try
-      {
-        Object bindaddr = impl.getOption (SocketOptions.SO_BINDADDR);
-      }
-    catch (SocketException e)
-      {
-        return false;
-      }
-    
-    return true;
+    return bound;
   }
 
   /**

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]