1 Reply Latest reply on Sep 4, 2015 7:34 AM by Billie Hecox

    Socket Exception in Android

    Sumeet Arora

      I am working on an Android Application in which I got stuck in an issue. The problem is that, "When I run this method mentioned below in code, I am getting an error of socket Exception ((Permission denied) i.e, java.net.SocketException: socket failed:). I tried many time to resolve this issue, but still getting experiencing this problem. I know this is an android developer forum community where I am seeking some solution. Please help me for resolving my query. Here is code please check and reply me asap.

      <code>

      1. public void run() {
      2.    // TODO Auto-generated method stub
      3.    URL url = null;
      4. try {
      5.    url = new URL("http url");
      6. }
      7. catch (MalformedURLException me) {
      8.    // TODO Auto-generated catch block
      9.    me.printStackTrace();
      10. }
      11. try {
      12.    URLConnection uelCon = url.openConnection();
      13.    InputStreamReader inputStreamReader = new InputStreamReader(BufferedInputStream(myconn.getInputStream()));
      14.    BufferedReader buffer = new BufferedReader(inputStreamReader);
      15.    String traverse;
      16.    StringBuilder builder = new StringBuilder();
      17.    while ((traverse=buffer.readLine()) != null)
      18.    {
      19.        builder.append(traverse);
      20.    }
      21. }
      22. catch (IOException ioe) {
      23.    // TODO Auto-generated catch block
      24.    ioe.printStackTrace();
      25. }
      26. super.run();
      27. }

      </code>