InetSocketAddress ipv4 = ...; // the IPv4 address
InetSocketAddress ipv6 = ...; // the IPv6 address
Socket sock = ...; // initialize a socket
sock.bind(ipv4);
sock.connect(ipv6, 0);
Both sides are IPv4/IPv6 dual stack support.
Can Java support for this kind of connection?
If the JDK could try to translate the binding address into a IPv6 one or translate the target address into a IPv4 one?
I tried case of bind IPv6 while connect to IPv4. JDK translate the binding IPv6 address into a IPv4 one during the connecting process. But when trying bind IPv4 while connect to IPv6 (as I mentioned above), I just got time out exception. I'm not sure if this is not support or some issue of my environment. I guess there should be some exception indicating not support thrown before connecting, not a time out finally.
Any idea? Thanks.