java.net.SocketException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • GitHub comment 1400#269891959
    via GitHub by jack16099
    ,
  • visual-c++: décembre 2014
    via by Unknown author,
    • java.net.SocketException: socket failed: EACCES (Permission denied) This is my method to post data to the server public void postData(String stuff){ //Create a new HTTPClient and Post Header URL url; HttpURLConnection con = null; status.setText("In post"); try{ url = new URL("http://myaddress/gpsin"); con = (HttpURLConnection)url.openConnection(); con.setDoOutput(true); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); con.connect(); //Send Request DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes((stuff)); wr.flush(); wr.close(); InputStream is; int response = con.getResponseCode(); if(response >= 200 && response<= 399){ //return success status.setText("Success!"); }else{ //return fail status.setText("Fail"); } } catch (Exception e){ e.printStackTrace(); status.setText("In catch"); }finally{ if(con!=null)con.disconnect(); } } Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jake.locationapp"> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> LogCat: 09-09 12:43:33.308 11819-11819/com.jake.locationapp W/System.err: java.net.SocketException: socket failed: EACCES (Permission denied) at libcore.io.IoBridge.socket(IoBridge.java:623) at java.net.PlainSocketImpl.create(PlainSocketImpl.java:198) at java.net.Socket.checkOpenAndCreate(Socket.java:689) at java.net.Socket.setSoTimeout(Socket.java:543) at com.android.okhttp.Connection.connect(Connection.java:158) at com.android.okhttp.Connection.connect(Connection.java:174) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:316) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:249) at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:397) at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:118) at com.jake.locationapp.MainActivity.postData(MainActivity.java:84) at com.jake.locationapp.MainActivity$MyLocationListener.onLocationChanged(MainActivity.java:197) at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:285) at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:214) at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:230) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5430) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706) Caused by: android.system.ErrnoException: socket failed: EACCES (Permission denied) at libcore.io.Posix.socket(Native Method) at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:282) at libcore.io.IoBridge.socket(IoBridge.java:608) ... 21 more

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,