title: Android Client socket , how to read data?
body: <p>here's my full code: the cnx is established , and i am sending data to server , but i cant read anything from the server...</p>
  
  <pre><code>public class client extends Activity
  {
      /** Called when the activity is first created. */
      Socket sock;
      String spliter = "**";
      String mobileNbr = "100";
      String LastJOKEId = "-1";
      String spliterlast = "^^$$";
      BufferedReader inFromServer;
      DataOutputStream outToServer;
      TextView cnx;
      TextView output;
  
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          setupNetworking();
          // Thread readerThread=new Thread(new IncomingReader());
          // readerThread.start();
      }
  
      private void setupNetworking()
      {
          try
          {
              Log.i("ClientActivity", "Connecting...");
              sock = new Socket("192.168.153.221", 9003);
              cnx = (TextView) findViewById(R.id.textView1);
              cnx.setText("Network Established.");
              inFromServer = new BufferedReader(new InputStreamReader(sock.getInputStream()));
              Log.i("ClientActivity", "Sending command.");
              outToServer = new DataOutputStream(sock.getOutputStream());
              String sentence = "logins" + spliter + mobileNbr + spliter + LastJOKEId + spliterlast;
              outToServer.writeBytes(sentence + '\n');
              Log.i("ClientActivity", "Sent.");
          }
          catch (UnknownHostException e)
          {
              e.printStackTrace();
          }
          catch (IOException e)
          {
              cnx = (TextView) findViewById(R.id.textView1);
              cnx.setText("Network failed");
              e.printStackTrace();
          }
      }
  
      public class IncomingReader implements Runnable
      {
          String message;
          public void run()
          {
              try
              {
                  while ((message = inFromServer.readLine()) != null)
                  {
                      output = (TextView) findViewById(R.id.textView2);
                      output.setText(message);
                  }
              }
              catch (IOException e)
              {
                  output = (TextView) findViewById(R.id.textView2);
                  output.setText("nth to display");
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>