title: The code Socket clientSocket = new Socket(); crashes in android app. Why?
body: <p>I am using a standard client code to send a string to my server. It works perfect when I am running a java project from eclipse but it doesn't work when I am running the same code via a button on my android application. After debugging I got my try code crashes in the line </p>
  
  <p>Socket clientSocket = new Socket("192.168.1.91", 6789);</p>
  
  <p>Please help me.</p>
  
  <pre><code>    public void button2OnClick(View k){
  
      //Testing Server Connection
      try{
  
          String sentence;
  
          String modifiedSentence;
          BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in));
          Socket clientSocket = new Socket("192.168.1.91", 6789);
          Button button=(Button) k;
          ((Button) k).setText("Done");
          DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
          BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
          sentence = "connection with android successful";
          outToServer.writeBytes(sentence + '\n');
          modifiedSentence = inFromServer.readLine();
          clientSocket.close();
  
  
      }
      catch(Exception IO){
  
      }
  
  
  
  }
  </code></pre>