Address family not supported by protocol exception
- by srg
I'm trying to send a couple of values from an android application to a web service which I've setup. I'm using Http Post to send them but when I run the application I get the error- request time failed java.net.SocketException: Address family not supported by protocol.
I get this while debugging with both the emulator as well as a device connected by wifi. I've already added the internet permission using:
<uses-permission android:name="android.permission.INTERNET" />
This is the code i'm using to send the values
void insertData(String name, String number) throws Exception {
String url = "http://192.168.0.12:8000/testapp/default/call/run/insertdbdata/";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
try {
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("a", name));
params.add(new BasicNameValuePair("b", number));
post.setEntity(new UrlEncodedFormEntity(params));
HttpResponse response = client.execute(post);
}catch(Exception e){
e.printStackTrace();
}
Also I know that my web service work fine because when I send the values from an html page it works fine -
<form name="form1" action="http://192.168.0.12:8000/testapp/default/call/run/insertdbdata/" method="post">
<input type="text" name="a"/>
<input type="text" name="b"/>
<input type="submit"/>
I've seen questions of similar problems but haven't really found a solution.
Thanks