Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid HTTP POST request error - socket failed EACCES (Permission denied)
    primarykey
    data
    text
    <p>I'm trying to send a POST request to my localhost from an Android app under <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29" rel="nofollow">Eclipse</a>, but I am receiving this error:</p> <blockquote> <p>socket failed EACCES (Permission denied).</p> </blockquote> <p>I'm doing this through the apache.commons library. I've tried to connect via HttpClient before, but there was a similar error:</p> <blockquote> <p>Connect to <strong>myhost</strong> refused.</p> </blockquote> <p>Here is the code:</p> <pre><code> public void onClick(View v) { login = (EditText) findViewById(R.id.entry_login); userLogin = login.getText().toString(); pwd = (EditText) findViewById(R.id.entry_password); userPwd = pwd.getText().toString(); BufferedReader br = null; HttpClient httpclient = new HttpClient(); PostMethod method = new PostMethod("http://127.0.0.1/testPost.php"); method.addParameter("name", "Arthur"); System.out.println("Login: " + userLogin); try { httpclient.executeMethod(method); int returnCode = httpclient.executeMethod(method); if (returnCode == HttpStatus.SC_NOT_IMPLEMENTED) { System.err.println("The Post method is not implemented by this URI"); // Still consume the response body method.getResponseBodyAsString(); } else { br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream())); String readLine; while (((readLine = br.readLine()) != null)) { System.err.println(readLine); } } /* List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2); nameValuePairs.add(new BasicNameValuePair("name", "Arthur")); nameValuePairs.add(new BasicNameValuePair("OP_ID", "10001")); nameValuePairs.add(new BasicNameValuePair("IP_ADDRESS", "127.0.0.1")); nameValuePairs.add(new BasicNameValuePair("FIELDS=field100", userLogin + "&amp;field101=" + userPwd)); nameValuePairs.add(new BasicNameValuePair("REQ_TYPE=", "26")); */ System.out.println("http connection done well!"); // response.getStatusLine(); } catch (Exception e) { System.out.println(e.getMessage()); } finally { method.releaseConnection(); if (br != null) try { br.close(); } catch (Exception fe) { } } } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload