Java Code Examples for io.netty.util.NetUtil#LOCALHOST6

The following examples show how to use io.netty.util.NetUtil#LOCALHOST6 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddressIpv6() throws Exception {
    Inet6Address address = NetUtil.LOCALHOST6;
    InetSocketAddress inetAddress = new InetSocketAddress(address, 9999);
    byte[] bytes = new byte[24];
    ByteBuffer buffer = ByteBuffer.wrap(bytes);
    buffer.put(address.getAddress());
    buffer.putInt(address.getScopeId());
    buffer.putInt(inetAddress.getPort());
    Assert.assertEquals(inetAddress, address(buffer.array(), 0, bytes.length));
}
 
Example 2
Source File: NativeTest.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddressIpv6() throws Exception {
    Inet6Address address = NetUtil.LOCALHOST6;
    InetSocketAddress inetAddress = new InetSocketAddress(address, 9999);
    byte[] bytes = new byte[24];
    ByteBuffer buffer = ByteBuffer.wrap(bytes);
    buffer.put(address.getAddress());
    buffer.putInt(address.getScopeId());
    buffer.putInt(inetAddress.getPort());
    Assert.assertEquals(inetAddress, Native.address(buffer.array(), 0, bytes.length));
}