title: Telnet. Android, hanging on send
body: <p>Im trying to send a command through telnet to my computer which then sends the command to a serial port, when using telnet using </p>
  
  <pre><code>adb shell
  $telnet 172.20.104.203 5334
  $h
  </code></pre>
  
  <p>it returns the data from the command h, how ever when I try to do this using android it connects to the socket, I can see this on the computer, it sends the command but then as soon as it logs that it has sent it hangs and comes up with "Application not responding" and it has wait or force close and if I wait it just stays the same. </p>
  
  <p>This is my code for the telnet part</p>
  
  <pre><code>    private static final int TCP_SERVER_PORT = 5334;
  
      private void runTcpClient() {
          try {
              Socket s = new Socket("172.20.104.203", TCP_SERVER_PORT);
              BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
              BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
              //send output msg
              String outMsg = "$getPos"; 
              out.write(outMsg);
              out.flush();
              Log.i("TcpClient", "sent: " + outMsg);
              //accept server response
              String inMsg = in.readLine() + System.getProperty("line.separator");
              Log.i("TcpClient", "received: " + inMsg);
              //close connection
              s.close();
          } catch (UnknownHostException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          } 
      }
  </code></pre>
  
  <p>It logs the send, but it never logs the receive, I thought it might be something to do with the amount of data being received so I just sent </p>
  
  <pre><code>$getPos 
  </code></pre>
  
  <p>instead but it still hangs. </p>
  
  <p>Any one know what could be happening?</p>