Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I connect to an IPv6 address on Android?

On Android, I'm using HttpClient to connect to a web address like so:

String url = "http://[fe80::1cef:49e7:2661:ffda]:7001/a.MOV";
HttpParams httpParameters = new BasicHttpParams();
HttpClient client = new DefaultHttpClient(httpParameters);
HttpGet httpGet = new HttpGet(url);
HttpResponse response = client.execute(httpGet);

The code works fine when inputting a standard URL, or one with a v4 IP address. However, when I use a v6 address, the last line of the above code will fail with a java.net.SocketException: Invalid argument being thrown.

To illustrate, while this address:

http://192.168.1.2:7001/a.MOV

will work without a problem, this one:

http://[fe80::1cef:49e7:2661:ffda]:7001/a.MOV

won't work at all.

To be sure, I also tried using the newer HttpURLConnection to make the connection, and it still results in the same exception being thrown.

I'm currently performing my testing on a Google TV device running Android version 3.2.

So is there something I'm doing wrong? And if not, is there any way to work around this apparent limitation of Android?

like image 816
yydl Avatar asked Oct 14 '25 23:10

yydl


1 Answers

Since you are using Android 3.2 It will not support ipv6

Check here https://android.stackexchange.com/questions/3718/does-android-have-support-for-ipv6

like image 163
Viswanath Lekshmanan Avatar answered Oct 17 '25 12:10

Viswanath Lekshmanan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!