title: Android-App in my phone stopped when connect to PC via socket
body: <p>I use my pc as a server, just build a socket.
  And in the client source, I just build a socket connecting to the pc. However when I open the App in my phone, it shows that the app is stopped...I have add the permission of Internet to the project. </p>
  
  <p>Server</p>
  
  <pre><code>public class Server extends Thread{
      private Socket client;
  
      public Server(Socket c){
          this.client = c;
      }
  
  
      public void run(){
          try{    
              //System.out.println("Start!");
              BufferedReader in = 
                      new BufferedReader(new InputStreamReader(client.getInputStream()));
              PrintWriter out = new PrintWriter(client.getOutputStream());
              while(true){
                  String str = in.readLine();
                  System.out.println(str);
                  out.println("has receive...");
                  out.flush();
                  if(str.equals("end"))
                      break;
              }
              client.close();
  
          }
          catch(IOException ex){
          }finally{
          }
      }
  
      public static void main(String[] args) throws IOException{
          ServerSocket server = new ServerSocket(2345);
          System.out.println("Start!");       
          while (true){
              Server sv = new Server(server.accept());
              sv.start();
          }
      }
  }
  </code></pre>
  
  <p>client:</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  
      Socket socket;
      DataInputStream dis;
      DataOutputStream dos;
  
      private TextView tv;
      private Button bt;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          tv = (TextView) findViewById(R.id.TextView1);
          bt = (Button) findViewById(R.id.button1);
          bt.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  try{
                      socket = new Socket("155.69.149.221",2345);
                      tv.setText("Connected!");
                  }catch(IOException ioe){
  
                  }
  
              }
          });
  
      }
  
  
  
  }
  </code></pre>