title: Android: Looking for a way to speed up Image Transfer from Android to PC over wifi
body: <p>I am trying to transfer images quickly between my Android phone and my PC over wifi. I have written code to do this but it can 4-5 seconds to transfer one 640x480px image across. I am wondering is my method flawed and is there a faster way to do this?</p>
  
  <p>Here is the Server code</p>
  
  <pre><code>void main(String[] args)
  {
          try {
               ServerSocket serverSocket = new ServerSocket(5555);
               Socket clientSocket = serverSocket.accept();
  
               long startTime = System.currentTimeMillis();
               InputStream clientInputStream = clientSocket.getInputStream();
               BufferedImage BI = ImageIO.read(clientInputStream);
               long endTime = System.currentTimeMillis();
               ImageIO.write(BI,"png",new File("test.png"));
               System.out.println((endTime - startTime) + " ms.");
  
               } catch (IOException e) 
               {
                  e.printStackTrace();
               }     
  }
  }
  </code></pre>
  
  <p>Here is the Android client code</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      Bitmap imageToSend = BitmapFactory.decodeResource(this.getResources(),R.drawable.img);
  
      try 
      {
          Socket socket = new Socket("192.168.1.1",5555);         
          imageToSend.compress(CompressFormat.PNG,0 , socket.getOutputStream());          
      }        
      catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Thank you for any help you can give.</p>