1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.testsuite.transport.socket;
17
18 import io.netty.channel.socket.DatagramChannel;
19 import io.netty.channel.socket.nio.NioDatagramChannel;
20 import io.netty.util.NetUtil;
21 import io.netty.util.internal.PlatformDependent;
22
23 import java.net.InetAddress;
24 import java.net.InetSocketAddress;
25 import java.net.SocketAddress;
26
27 public class DatagramUnicastIPv6MappedTest extends DatagramUnicastIPv6Test {
28
29 @Override
30 protected SocketAddress newSocketAddress() {
31 return new InetSocketAddress(0);
32 }
33
34 @Override
35 protected InetSocketAddress sendToAddress(InetSocketAddress serverAddress) {
36 InetAddress addr = serverAddress.getAddress();
37 if (addr.isAnyLocalAddress()) {
38 return new InetSocketAddress(NetUtil.LOCALHOST4, serverAddress.getPort());
39 }
40 return serverAddress;
41 }
42
43 @Override
44 protected boolean disconnectMightFail(DatagramChannel channel) {
45
46 if (channel instanceof NioDatagramChannel && PlatformDependent.javaVersion() < 20) {
47 return true;
48 }
49 return super.disconnectMightFail(channel);
50 }
51 }