< prev index next >

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

Print this page

        

*** 41,51 **** 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. --- 41,50 ----
*** 156,171 **** 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); ! } connectToAddress(address, port, timeout); connected = true; } finally { if (!connected) { --- 155,166 ---- throws UnknownHostException, IOException { boolean connected = false; try { InetAddress address = InetAddress.getByName(host); this.port = port; ! this.address = address; connectToAddress(address, port, timeout); connected = true; } finally { if (!connected) {
*** 185,200 **** * 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); ! } try { connectToAddress(address, port, timeout); isConnected = true; return; --- 180,191 ---- * the specified port. * @param address the address * @param port the specified port */ protected void connect(InetAddress address, int port) throws IOException { this.port = port; ! this.address = address; try { connectToAddress(address, port, timeout); isConnected = true; return;
*** 222,239 **** 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); connected = true; } finally { if (!connected) { try { close(); --- 213,226 ---- if (address == null || !(address instanceof InetSocketAddress)) throw new IllegalArgumentException("unsupported address type"); InetSocketAddress addr = (InetSocketAddress) address; if (addr.isUnresolved()) throw new UnknownHostException(addr.getHostName()); this.port = addr.getPort(); ! this.address = addr.getAddress(); ! ! connectToAddress(this.address, port, timeout); connected = true; } finally { if (!connected) { try { close();
*** 457,470 **** } 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); } 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); --- 444,454 ---- } 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 ) { ! 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,511 **** } 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; } 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)) { --- 480,490 ---- } 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) { ! 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,569 **** synchronized (fdLock) { if (!closePending && !isBound) { NetHooks.beforeTcpBind(fd, address, lport); } } - if (address.isLinkLocalAddress()) { - address = IPAddressUtil.toScopedAddress(address); - } socketBind(address, lport); isBound = true; } /** --- 536,545 ----
< prev index next >