You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2006/08/28 10:04:30 UTC

svn commit: r437591 - /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java

Author: pyang
Date: Mon Aug 28 01:04:29 2006
New Revision: 437591

URL: http://svn.apache.org/viewvc?rev=437591&view=rev
Log:
Patch applied for HARMONY-1278 ([classlib][nio]Bug in SocketChannel.connect(SocketAddress))

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java?rev=437591&r1=437590&r2=437591&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java Mon Aug 28 01:04:29 2006
@@ -262,12 +262,10 @@
             if (!isBound) {
                 // bind
                 networkSystem.bind2(fd, 0, true, InetAddress
-                        .getByAddress(localAddrArray));
+                        .getByAddress(new byte[] { 0, 0, 0, 0 }));
+                isBound = true;
             }
 
-            localPort = networkSystem.getSocketLocalPort(fd, false);
-            localAddress = networkSystem.getSocketLocalAddress(fd, false);
-
             if (isBlocking()) {
                 begin();
                 result = networkSystem.connect(fd, trafficClass,
@@ -301,6 +299,10 @@
             }
         }
 
+        // set local port
+        localPort = networkSystem.getSocketLocalPort(fd, false);
+        localAddress = networkSystem.getSocketLocalAddress(fd, false);
+        
         // set the connected address.
         connectAddress = inetSocketAddress;
         synchronized (this) {
@@ -347,6 +349,8 @@
                         HY_PORT_SOCKET_STEP_CHECK, connectContext);
             }
             finished = (result == CONNECT_SUCCESS);
+            isBound = finished;
+            localAddress = networkSystem.getSocketLocalAddress(fd, false);
         } catch (ConnectException e) {
             if (isOpen()){
                 close();
@@ -748,6 +752,32 @@
             }
         }
 
+        
+        public boolean getReuseAddress() throws SocketException {
+            checkOpen();
+            return ((Boolean) socketImpl.getOption(SocketOptions.SO_REUSEADDR))
+                    .booleanValue();
+        }
+        
+        public synchronized int getReceiveBufferSize() throws SocketException {
+            checkOpen();
+            return ((Integer) socketImpl.getOption(SocketOptions.SO_RCVBUF)).intValue();
+        }
+        
+        public synchronized int getSendBufferSize() throws SocketException {
+            checkOpen();
+            return ((Integer) socketImpl.getOption(SocketOptions.SO_SNDBUF)).intValue();
+        }
+        
+        public synchronized int getSoTimeout() throws SocketException {
+            checkOpen();
+            return ((Integer) socketImpl.getOption(SocketOptions.SO_TIMEOUT)).intValue();
+        }
+        
+        public int getTrafficClass() throws SocketException {
+            checkOpen();
+            return ((Number) socketImpl.getOption(SocketOptions.IP_TOS)).intValue();
+        }
         /*
          * 
          * @see java.net.Socket#getKeepAlive()