< prev index next >

src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java

Print this page

        

@@ -41,11 +41,10 @@
 import sun.net.ConnectionResetException;
 import sun.net.NetHooks;
 import sun.net.PlatformSocketImpl;
 import sun.net.ResourceManager;
 import sun.net.ext.ExtendedSocketOptions;
-import sun.net.util.IPAddressUtil;
 import sun.net.util.SocketExceptions;
 
 /**
  * Default Socket Implementation. This implementation does
  * not implement any security checks.

@@ -156,16 +155,12 @@
         throws UnknownHostException, IOException
     {
         boolean connected = false;
         try {
             InetAddress address = InetAddress.getByName(host);
-            // recording this.address as supplied by caller before calling connect
-            this.address = address;
             this.port = port;
-            if (address.isLinkLocalAddress()) {
-                address = IPAddressUtil.toScopedAddress(address);
-            }
+            this.address = address;
 
             connectToAddress(address, port, timeout);
             connected = true;
         } finally {
             if (!connected) {

@@ -185,16 +180,12 @@
      * the specified port.
      * @param address the address
      * @param port the specified port
      */
     protected void connect(InetAddress address, int port) throws IOException {
-        // recording this.address as supplied by caller before calling connect
-        this.address = address;
         this.port = port;
-        if (address.isLinkLocalAddress()) {
-            address = IPAddressUtil.toScopedAddress(address);
-        }
+        this.address = address;
 
         try {
             connectToAddress(address, port, timeout);
             isConnected = true;
             return;

@@ -222,18 +213,14 @@
             if (address == null || !(address instanceof InetSocketAddress))
                 throw new IllegalArgumentException("unsupported address type");
             InetSocketAddress addr = (InetSocketAddress) address;
             if (addr.isUnresolved())
                 throw new UnknownHostException(addr.getHostName());
-            // recording this.address as supplied by caller before calling connect
-            InetAddress ia = addr.getAddress();
-            this.address = ia;
             this.port = addr.getPort();
-            if (ia.isLinkLocalAddress()) {
-                ia = IPAddressUtil.toScopedAddress(ia);
-            }
-            connectToAddress(ia, port, timeout);
+            this.address = addr.getAddress();
+
+            connectToAddress(this.address, port, timeout);
             connected = true;
         } finally {
             if (!connected) {
                 try {
                     close();

@@ -457,14 +444,11 @@
         } else if (name == StandardSocketOptions.SO_REUSEADDR) {
             setOption(SocketOptions.SO_REUSEADDR, value);
         } else if (name == StandardSocketOptions.SO_REUSEPORT) {
             setOption(SocketOptions.SO_REUSEPORT, value);
         } else if (name == StandardSocketOptions.SO_LINGER ) {
-            if (((Integer)value).intValue() < 0)
-                setOption(SocketOptions.SO_LINGER, false);
-            else
-                setOption(SocketOptions.SO_LINGER, value);
+            setOption(SocketOptions.SO_LINGER, value);
         } else if (name == StandardSocketOptions.IP_TOS) {
             int i = ((Integer)value).intValue();
             if (i < 0 || i > 255)
                 throw new IllegalArgumentException("Invalid IP_TOS value: " + value);
             setOption(SocketOptions.IP_TOS, value);

@@ -496,16 +480,11 @@
         } else if (name == StandardSocketOptions.SO_REUSEADDR) {
             return (T)getOption(SocketOptions.SO_REUSEADDR);
         } else if (name == StandardSocketOptions.SO_REUSEPORT) {
             return (T)getOption(SocketOptions.SO_REUSEPORT);
         } else if (name == StandardSocketOptions.SO_LINGER) {
-            Object value = getOption(SocketOptions.SO_LINGER);
-            if (value instanceof Boolean) {
-                assert ((Boolean)value).booleanValue() == false;
-                value = -1;
-            }
-            return (T)value;
+            return (T)getOption(SocketOptions.SO_LINGER);
         } else if (name == StandardSocketOptions.IP_TOS) {
             return (T)getOption(SocketOptions.IP_TOS);
         } else if (name == StandardSocketOptions.TCP_NODELAY) {
             return (T)getOption(SocketOptions.TCP_NODELAY);
         } else if (extendedOptions.isOptionSupported(name)) {

@@ -557,13 +536,10 @@
        synchronized (fdLock) {
             if (!closePending && !isBound) {
                 NetHooks.beforeTcpBind(fd, address, lport);
             }
         }
-        if (address.isLinkLocalAddress()) {
-            address = IPAddressUtil.toScopedAddress(address);
-        }
         socketBind(address, lport);
         isBound = true;
     }
 
     /**
< prev index next >