title: Android Socket error in client-server app
body: <p>When I want to make connection with my server my android application is crashing on the line where a make a new socket.</p>
  
  <p>The code where I make the connection in my ClientAppl.java looks like this.</p>
  
  <pre><code>public class ClientAppl {
  private InetAddress host;
  private int port;
  private Socket link = null;
  ObjectInputStream istream;
  ObjectOutputStream ostream;
  private static MainActivity mainActivity;
  private static ClientAppl instance = new ClientAppl(mainActivity);
  
  
  private ClientAppl(MainActivity frm){
  ClientAppl.mainActivity = frm;
  }
  
  public static ClientAppl getInstance(){
  return instance;
  }
  
  public void makeConnection(String sIP, int port) throws IOException, java.net.ConnectException{
      if(link == null){
  
      System.out.println("Make connection...");
      this.host = InetAddress.getByName(sIP);
          this.port = port;
          link = new Socket(host, port);
  
          System.out.println("Inputkanaal &amp; outputkanaal vastleggen...");
          ostream = new ObjectOutputStream(link.getOutputStream());
          System.out.println("OK - output");
          istream = new ObjectInputStream(link.getInputStream());
          System.out.println("OK - input");
  
          AcceptMessageHandler amh = new AcceptMessageHandler();
          Thread t = new Thread(amh);
          t.start();
      }
  }
  </code></pre>
  
  <p>In MainActivity.java I added this code to start a connection.</p>
  
  <pre><code>txtServerIP = (EditText)findViewById(R.id.txtServerIP);
  txtServerPoort = (EditText)findViewById(R.id.txtServerPoort);
  try {
  ClientAppl.getInstance().makeConnection(txtServerIP.getText().toString(),    Integer.parseInt(txtServerPoort.getText().toString()));
  } catch (NumberFormatException e) {
  e.printStackTrace();
  } catch (UnknownHostException e) {
  e.printStackTrace();
  } catch (ConnectException e) {
  e.printStackTrace();
  } catch (IOException e) {
  e.printStackTrace();
  }
  </code></pre>
  
  <p>And this is my manifest-file. What's wrong? :(</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="be.howest"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk android:minSdkVersion="15" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET"&gt;
  &lt;/uses-permission&gt;
  &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name"&gt;
      &lt;activity
          android:name="project.client.pc.view.MainActivity"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>