harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r437591 - /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java
Date Mon, 28 Aug 2006 08:04:30 GMT
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()



Mime
View raw message