Can not connect lo localhot from emulator using socket

by Oskeol » Fri, 09 May 2008 16:01:35 GMT


Sponsored Links
 Hi,
I want to access an Eccho server in localhost.

Here is the Echo server in localhost




import java.net.*;
import java.io.*;
import java.util.Scanner;


public class EchoServer
{
        public static void main(String[] args)
        {
                try
                {
                        ServerSocket s = new ServerSocket(8189);
                        Socket incoming = s.accept();

                        try
                        {
                                InputStream inStream   = 
incoming.getInputStream();
                                OutputStream outStream = 
incoming.getOutputStream();
                                Scanner in = new Scanner(inStream);
                                PrintWriter out = new PrintWriter(outStream, 
true);
                                out.println("Hello! Enter BYE to exit");

                                boolean done = false;

                                while(!done && in.hasNextLine())
                                {
                                        String line = in.nextLine();
                                        out.println("Echo: "+ line);
                                        if(line.trim().equalsIgnoreCase("BYE"))
                                                done = true;
                                }

                        }
                        finally
                        {
                                incoming.close();
                        }

                }
                catch(IOException e)
                {
                        e.printStackTrace();
                }

    }
}


I have a client, on the emulatot that tries to connect to this server.
I use 10.0.2.2 to connect to localhost, but it doesn't work.

Socket s = new Socket("10.0.2.2", 8189);

Can anybody explain why this happen,

oskeol
--~--~---------~--~----~------------~-------~--~----~



Can not connect lo localhot from emulator using socket

by kobica » Mon, 12 May 2008 17:15:56 GMT


 >

have you tried to forward/redirect ports?
Maybe that is what you are missing.

Plus, take a look at:


Sponsored Links


Can not connect lo localhot from emulator using socket

by Oskeol » Tue, 13 May 2008 20:31:26 GMT


 Thanks, very much for your help.
Forwarding ports it does now work.

Thnx agani Kobi,

Oskeol
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Support from Developers

I have been in discussion with a few devs not quite content with the
ratings/feedback system currently in place on the Android Market, and
had the following idea:

If there was a Developer Only Market, things would be _much_ more
civil,
professional, and productive for all involved. Particularly because we
could
all relate to each other with empathy, and there would be less
anonymity,
especially if it required registration. There would be a less people
to
present to, but the quality of user helpfulness would be more
concentrated.
It could serve as a place to test release apps before jumping into the
swarm
that is the current Market, or a place to seek genuinely constructive
feedback.


Anyone have any thoughts on this?

--~--~---------~--~----~------------~-------~--~----~

2. News via WSJ ... 1 Million + G-Phones Sold So Far

kinda of useless the link, can't read it, and bugmenot says is a banned
domain or something like that







--~--~---------~--~----~------------~-------~--~----~

3. the imageview object supports which formats images other than png and jpg

4. Test on real phone

5. Injecting HTTP header into all requests issued by the emulator

6. Storing images as blob in sqlite

7. Style Attributes