I am developing an Android application and I need to use IPv6 to connect to a server.
IPv6 is enabled on the phone and I can see my local IPv6 address with ip addr
. I can also successfully ping6
my phone from the PC and viceversa.
But hen I try to get local addresses on Android through the Java command NetworkInterface.getNetworkInterfaces()
I only get IPv4 addresses.
I also tryed to open a client socket but the line
Socket s = new Socket(MYSERVERIPV6ADDRESS, PORT);
always throws java.net.SocketException: Invalid argument
.
I am sure the address is correct because I tryed with the same code on my computer and works perfectly.
It seems that IPv6 is supported by the operating system but not by the Java virtual machine. Is there a way to solve this problem?
No, as of late 2013, even the newest Android devices still don't support IPv6-only WiFi networks.
The goal of the IPv6 service is to provide the same service as IPv4, but with the much more modern IPv6 protocol which will allow the entire Internet to grow larger than what was planned 30 years ago with IPv4. IPv6 is live on the standard epc.tmobile.com and fast.t-mobile.com APN.
Use this static method in Inet6Address to get a Inet6Address object for your address,
Inet6Address getByAddress (String host, byte[] addr, int scope_id)
then use, the following socket constructor to get a socket,
Socket(InetAddress dstAddress, int dstPort).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With