I am getting the following exception when i run my android app: I am getting inside the asynctask but logging this exception.
03-15 16:49:21.456 16854-16892/com.ashwinbhy.phpwrite W/Ashwin﹕ java.net.SocketException: socket failed: EACCES (Permission denied)
I have included this permissions inside my manifest.xml:
<uses-permission android:name="android.permission.internet"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.access_network_state"/>
The code is:
try {
URL url = new URL("http://10.0.0.2/tt.php");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000);
conn.setConnectTimeout(15000);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
Uri.Builder builder = new Uri.Builder()
.appendQueryParameter("bus_id", busid)
.appendQueryParameter("lat", lat)
.appendQueryParameter("lon", lon);
String query = builder.build().getEncodedQuery();
OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
writer.write(query);
writer.flush();
writer.close();
os.close();
conn.connect();
}
catch(Exception e){
Log.w("Ashwin",e.toString()+"inside the exception log");
return "error";
}
Can someone please point where am i going wrong ?
I am addding the log:
03-15 17:15:42.140 9003-9034/com.ashwinbhy.phpwrite I/System.out﹕ open:http://10.0.0.2/tt.php
03-15 17:15:42.141 9003-9034/com.ashwinbhy.phpwrite D/libc-netbsd﹕ [getaddrinfo]: hostname=10.0.0.2; servname=(null); cache_mode=(null), netid=0; mark=0
03-15 17:15:42.141 9003-9034/com.ashwinbhy.phpwrite D/libc-netbsd﹕ [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
03-15 17:15:42.142 9003-9034/com.ashwinbhy.phpwrite I/System.out﹕ [CDS][DNS] getAllByNameImpl netId = 0
03-15 17:15:42.142 9003-9034/com.ashwinbhy.phpwrite D/libc-netbsd﹕ [getaddrinfo]: hostname=10.0.0.2; servname=(null); cache_mode=(null), netid=0; mark=0
03-15 17:15:42.142 9003-9034/com.ashwinbhy.phpwrite D/libc-netbsd﹕ [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
03-15 17:15:42.143 9003-9034/com.ashwinbhy.phpwrite I/System.out﹕ [CDS]rx timeout:10000
03-15 17:15:42.143 9003-9034/com.ashwinbhy.phpwrite I/System.out﹕ [socket][3] connection /10.0.0.2:80;LocalPort=55951(15000)
03-15 17:15:42.143 9003-9034/com.ashwinbhy.phpwrite I/System.out﹕ [CDS]connect[/10.0.0.2:80] tm:15