title: My android application has a client socket based on ASyncTask that seems broken
body: <p>I'm trying to use ASyncTask to handle networking in the background of my android application. Anything happening in SendData is in a separate thread.  The background thread begins to run, printing the first two log messages.  Then it hangs.  I'm quite new to both android and sockets so I wouldn't be surprised if this has many errors.  </p>
  
  <pre><code>package light24bulbs.ioio.testing;
  
  import ioio.lib.api.exception.ConnectionLostException;
  import ioio.lib.util.BaseIOIOLooper;
  import ioio.lib.util.IOIOLooper;
  import ioio.lib.util.android.IOIOActivity;
  import android.os.Bundle;
  import android.widget.SeekBar;
  import android.widget.Button;
  import android.widget.Toast;
  import ioio.lib.api.PwmOutput;
  import android.view.*;
  import android.widget.TextView;
  import android.util.Log;
  import light24bulbs.ioio.testing.R;
  import java.io.*;
  import java.net.*;
  import android.os.AsyncTask;
  import android.view.View.*;
  
  public class MainActivity extends IOIOActivity {
      private SeekBar bar_;
      private final int servoPin = 11;
      private final int freq = 100;
      private final String serverIP="192.168.1.41";
      TextView progressText;
      Button open;
      int progress;
      SendData senddata;
  
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          bar_ = (SeekBar) findViewById(R.id.seekBar1);
          TextView progressText = (TextView) findViewById(R.id.textView1);
          open = (Button) findViewById(R.id.start);
          open.setOnClickListener(openSocket);
          senddata = new SendData();
          senddata.execute(serverIP,null,null);
  
  
      }
  
  
      class Looper extends BaseIOIOLooper {
          /** The on-board LED. */
          private PwmOutput servo_;
  
          //happens when IOIO module is connected
          @Override
          protected void setup() throws ConnectionLostException {
  
              servo_ = ioio_.openPwmOutput(servoPin, freq);
  
  
  
          }
  
  //loops forever once everything else has been set up
          @Override
          public void loop() throws ConnectionLostException {
  
              servo_.setPulseWidth(600+(bar_.getProgress()*20));
              //servo_.setPulseWidth(800);
               progress = bar_.getProgress();
               senddata.onProgressUpdate(progress);
  
               try{
                   Thread.sleep(20);
               }catch(InterruptedException e){
  
               }
          }
      }
  
      @Override
      protected IOIOLooper createIOIOLooper() {
          return new Looper();
      }
  
  
  private class SendData extends AsyncTask&lt;String, Integer, Boolean&gt;{
      Socket clientSocket;
      DataOutputStream toServer;
      PrintStream pStream;
      @Override
      protected Boolean doInBackground(String... IP){
          Log.i("AsyncTask","doInBackground started running");
          Log.i("AsyncTask","attempting to connect to ip: "+IP[0]);
          try{
  
  
          clientSocket = new Socket(IP[0],4488);
          Log.i("AsyncTask","Created socket"+String.valueOf(clientSocket));
          toServer = new DataOutputStream(clientSocket.getOutputStream());
          }catch(IOException e){
              Log.i("AsyncTask","IO Exception while connecting socket- doInbackground()");
              return false;
          }
          Log.i("AsyncTask","Port connected! "+IP[0]);
          return true;
      }
      @Override
      protected void onProgressUpdate(Integer...pos){
          try{
          toServer.writeBytes(String.valueOf(pos[0]));
          }catch(IOException e){
              Log.i("AsyncTask","Failed to send the position");
          }
      }
  
  
  
  
  
  }
  }
  </code></pre>