@Test public void testSocketAddressToUaddrIPv6() throws Exception { String uaddr = "fe80:0:0:0:21c:c0ff:fea0:caf4.203.81"; InetSocketAddress socketAddress = new InetSocketAddress(InetAddress.getByName("fe80::21c:c0ff:fea0:caf4"), 52049); assertEquals("reverce convertion failed", uaddr, InetSocketAddresses.uaddrOf(socketAddress)); }
public static String uaddrOf(InetSocketAddress socketAddress) { int port = socketAddress.getPort(); int port_part[] = new int[2]; port_part[0] = (port & 0xff00) >> 8; port_part[1] = port & 0x00ff; InetAddress address = socketAddress.getAddress(); String s = address.getHostAddress(); if(address instanceof Inet6Address) { s = stripScopeId(s); } return s + "." + port_part[0] + "." + port_part[1]; }
InetSocketAddresses { public static String uaddrOf(InetSocketAddress socketAddress) { int port = socketAddress.getPort(); int port_part[] = new int[2]; port_part[0] = (port & 0xff00) >> 8; port_part[1] = port & 0x00ff; InetAddress address = socketAddress.getAddress(); String s = address.getHostAddress(); if(address instanceof Inet6Address) { s = stripScopeId(s); } return s + "." + port_part[0] + "." + port_part[1]; } }
InetSocketAddresses { public static String uaddrOf(InetSocketAddress socketAddress) { int port = socketAddress.getPort(); int port_part[] = new int[2]; port_part[0] = (port & 0xff00) >> 8; port_part[1] = port & 0x00ff; InetAddress address = socketAddress.getAddress(); String s = address.getHostAddress(); if(address instanceof Inet6Address) { s = stripScopeId(s); } return s + "." + port_part[0] + "." + port_part[1]; } private  InetSocketAddresses(); }
InetSocketAddresses { public static String uaddrOf(InetSocketAddress socketAddress) { int port = socketAddress.getPort(); int port_part[] = new int[2]; port_part[0] = (port & 0xff00) >> 8; port_part[1] = port & 0x00ff; InetAddress address = socketAddress.getAddress(); String s = address.getHostAddress(); if(address instanceof Inet6Address) { s = stripScopeId(s); } return s + "." + port_part[0] + "." + port_part[1]; } private  InetSocketAddresses(); static InetSocketAddress forUaddrString(String uaddr); static InetSocketAddress inetAddressOf(String address); static String uaddrOf(InetSocketAddress socketAddress); static String uaddrOf(String host, int port); static String tcpNetidOf(InetAddress address); }
InetSocketAddresses { public static String uaddrOf(InetSocketAddress socketAddress) { int port = socketAddress.getPort(); int port_part[] = new int[2]; port_part[0] = (port & 0xff00) >> 8; port_part[1] = port & 0x00ff; InetAddress address = socketAddress.getAddress(); String s = address.getHostAddress(); if(address instanceof Inet6Address) { s = stripScopeId(s); } return s + "." + port_part[0] + "." + port_part[1]; } private  InetSocketAddresses(); static InetSocketAddress forUaddrString(String uaddr); static InetSocketAddress inetAddressOf(String address); static String uaddrOf(InetSocketAddress socketAddress); static String uaddrOf(String host, int port); static String tcpNetidOf(InetAddress address);  }