equal
deleted
inserted
replaced
48 import java.security.AccessController; |
48 import java.security.AccessController; |
49 import java.security.PrivilegedAction; |
49 import java.security.PrivilegedAction; |
50 import java.util.Enumeration; |
50 import java.util.Enumeration; |
51 |
51 |
52 import sun.net.ext.ExtendedSocketOptions; |
52 import sun.net.ext.ExtendedSocketOptions; |
|
53 import sun.net.util.IPAddressUtil; |
53 import sun.security.action.GetPropertyAction; |
54 import sun.security.action.GetPropertyAction; |
54 |
55 |
55 public class Net { |
56 public class Net { |
56 |
57 |
57 private Net() { } |
58 private Net() { } |
460 static void bind(ProtocolFamily family, FileDescriptor fd, |
461 static void bind(ProtocolFamily family, FileDescriptor fd, |
461 InetAddress addr, int port) throws IOException |
462 InetAddress addr, int port) throws IOException |
462 { |
463 { |
463 boolean preferIPv6 = isIPv6Available() && |
464 boolean preferIPv6 = isIPv6Available() && |
464 (family != StandardProtocolFamily.INET); |
465 (family != StandardProtocolFamily.INET); |
|
466 if (addr.isLinkLocalAddress()) { |
|
467 addr = IPAddressUtil.toScopedAddress(addr); |
|
468 } |
465 bind0(fd, preferIPv6, exclusiveBind, addr, port); |
469 bind0(fd, preferIPv6, exclusiveBind, addr, port); |
466 } |
470 } |
467 |
471 |
468 private static native void bind0(FileDescriptor fd, boolean preferIPv6, |
472 private static native void bind0(FileDescriptor fd, boolean preferIPv6, |
469 boolean useExclBind, InetAddress addr, |
473 boolean useExclBind, InetAddress addr, |
479 } |
483 } |
480 |
484 |
481 static int connect(ProtocolFamily family, FileDescriptor fd, InetAddress remote, int remotePort) |
485 static int connect(ProtocolFamily family, FileDescriptor fd, InetAddress remote, int remotePort) |
482 throws IOException |
486 throws IOException |
483 { |
487 { |
|
488 if (remote.isLinkLocalAddress()) { |
|
489 remote = IPAddressUtil.toScopedAddress(remote); |
|
490 } |
484 boolean preferIPv6 = isIPv6Available() && |
491 boolean preferIPv6 = isIPv6Available() && |
485 (family != StandardProtocolFamily.INET); |
492 (family != StandardProtocolFamily.INET); |
486 return connect0(preferIPv6, fd, remote, remotePort); |
493 return connect0(preferIPv6, fd, remote, remotePort); |
487 } |
494 } |
488 |
495 |