title: Socket connection between local PC server and android emulator
body: <p>I have troubles with socket connection of PC (simple server written on Java) and android emulator. Connection is established, server sends data but when I try to read it on android it always reads a null-string. Here is some parts of my code:</p>
  
  <p>Server:</p>
  
  <pre><code>serverSocket = new ServerSocket(8888);
  socket = serverSocket.accept();
  PrintWriter output = new PrintWriter(socket.getOutputStream(), true);
  output.write("Output string");
  socket.close();
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>socket = new Socket("10.0.2.2", 8888);
  input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  String s = input.readLine();
  Log.i(TAG, s);
  socket.close();
  </code></pre>
  
  <p>I've omitted try-catches and logs for clearness. According to logs, connection is established, server sends data, but client receives only null-strings. I'd appreciate any help.</p>