Transfer of images from Local Computer(server) to the android emulator (client) via wifi
<p>I am having trouble transferring images from the local computer that is the server to the android emulator that is client. I am trying to capture a screen shot of the local computer and pass it to the android emulator. By far, I know that the screenshots have worked successfully(because I have tried to save it in a folder and it saved.) So I think the problem is in the socket connection part.I think that the problem is within the server code.I need UDP connection in this connection. Please I need the answer ASAP.</p>

<ol>
<li><p>The following code is of the server portion:</p>

<pre><code>public void run() {     
try
{
    srvCon = new ServerSocket(imagePort, 10);
    //srvCon.setSoTimeout(1000);
    while (ImageServer.isRunning)
    {  
        con = srvCon.accept();
        outStream = new ObjectOutputStream(con.getOutputStream());
        outStream.flush();
        BufferedImage img = robot.createScreenCapture(size);
        ImageIO.write(img, "jpeg", outStream);


    }
}
catch (IOException ioExp)
{

    ioExp.printStackTrace();
}
finally
{
    try
    {
        //inStream.close();
        outStream.close();
        //con.close();
        srvCon.close();
    }
    catch(IOException ioExp)
    {
        ioExp.printStackTrace();
    }
}
</code></pre>

<p>}</p></li>
<li><p>The following code is of android emulator code for receiving images:</p>

<pre><code>try 
{
    sock=new Socket("10.0.2.2",5557);
    input = new ObjectInputStream(sock.getInputStream());
    if(input!=null)
    {
        imageScreen = (ImageViewTouch) findViewById(R.id.imgScreen);
        Bitmap bmp = null;
        bmp= BitmapFactory.decodeStream(input);
    imageScreen.setImageBitmapReset(bmp, true);
    }
    else
    {
        System.out.printf("something wrong occured");
    }
    input.close();
    sock.close();
}
catch (UnknownHostException e) 
{
    e.printStackTrace();
} 
catch (IOException e) 
{
    e.printStackTrace();
}
</code></pre></li>
</ol>
