[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: server socket fixes

Kaffe CVS cvs-commits at kaffe.org
Fri Jun 10 15:41:57 PDT 2005


PatchSet 6618 
Date: 2005/06/10 22:37:02
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: server socket fixes

Members: 
	ChangeLog:1.4144->1.4145 
	libraries/javalib/java/net/ServerSocket.java:1.30->1.31 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4144 kaffe/ChangeLog:1.4145
--- kaffe/ChangeLog:1.4144	Fri Jun 10 22:29:54 2005
+++ kaffe/ChangeLog	Fri Jun 10 22:37:02 2005
@@ -4,6 +4,20 @@
 
 	2005-05-31  Jeroen Frijters  <jeroen at frijters.net>
 
+	* java/net/ServerSocket.java
+	(bound): Removed.
+	(local): New field.
+	(bind): Cache local socket address.
+	(getInetAddress, getLocalPort, getLocalSocketAddress, isBound):
+	Use cached local socket address.
+	(close): bound field was removed.
+
+2005-06-10  Dalibor Topic  <robilad at kaffe.org>
+
+	Resynced with GNU Classpath.
+
+	2005-05-31  Jeroen Frijters  <jeroen at frijters.net>
+
 	* gnu/java/nio/channels/FileChannelImpl.java
 	(FileChannelImpl()): Removed.
 	(FileChannelImpl(File,int)): Made private.
Index: kaffe/libraries/javalib/java/net/ServerSocket.java
diff -u kaffe/libraries/javalib/java/net/ServerSocket.java:1.30 kaffe/libraries/javalib/java/net/ServerSocket.java:1.31
--- kaffe/libraries/javalib/java/net/ServerSocket.java:1.30	Sun Apr 24 10:08:10 2005
+++ kaffe/libraries/javalib/java/net/ServerSocket.java	Fri Jun 10 22:37:04 2005
@@ -76,9 +76,9 @@
   private SocketImpl impl;
 
   /**
-   * True if socket is bound.
+   * We need to retain the local address even after the socket is closed.
    */
-  private boolean bound;
+  private InetSocketAddress local;
 
   /*
    * This constructor is only used by java.nio.
@@ -238,7 +238,9 @@
       {
 	impl.bind(addr, tmp.getPort());
 	impl.listen(backlog);
-	bound = true;
+	local = new InetSocketAddress(
+            (InetAddress) impl.getOption(SocketOptions.SO_BINDADDR),
+            impl.getLocalPort());
       }
     catch (IOException exception)
       {
@@ -264,18 +266,10 @@
    */
   public InetAddress getInetAddress()
   {
-    if (! isBound())
+    if (local == null)
       return null;
 
-    try
-      {
-	return (InetAddress) impl.getOption(SocketOptions.SO_BINDADDR);
-      }
-    catch (SocketException e)
-      {
-	// This never happens as we are bound.
-	return null;
-      }
+    return local.getAddress();
   }
 
   /**
@@ -285,10 +279,10 @@
    */
   public int getLocalPort()
   {
-    if (! isBound())
+    if (local == null)
       return -1;
 
-    return impl.getLocalPort();
+    return local.getPort();
   }
 
   /**
@@ -300,10 +294,7 @@
    */
   public SocketAddress getLocalSocketAddress()
   {
-    if (! isBound())
-      return null;
-
-    return new InetSocketAddress(getInetAddress(), getLocalPort());
+    return local;
   }
 
   /**
@@ -393,7 +384,6 @@
 
     impl.close();
     impl = null;
-    bound = false;
 
     if (getChannel() != null)
       getChannel().close();
@@ -424,7 +414,7 @@
    */
   public boolean isBound()
   {
-    return bound;
+    return local != null;
   }
 
   /**




More information about the kaffe mailing list