how can emulator access my server

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

how can emulator access my server

Postby mishmish » Tue Apr 26, 2011 9:28 am

how can i make the emulator access my server
iam making an application on android its my first app
but i dont know how to access the localhost
i tried

Socket socket = new Socket("localhost",1234);

i also tried 127.0.0.1 and 10.0.2.2
but still not working i changed to port using 5554 and many others ports but still not working :(

try
{
Socket socket = new Socket("localhost",1234);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
System.out.println("Received string: "+in.readLine());
in.close();
}
catch(Exception e)
{
System.out.println("Whoops! It didn't work! \n");
}



plzzzzzzzzz help :(
mishmish
Freshman
Freshman
 
Posts: 2
Joined: Tue Apr 26, 2011 9:08 am

Top

Re: how can emulator access my server

Postby pirko » Wed May 04, 2011 2:10 pm

You can't use localhost or 127.0.0.1 in the emulator because it's the emulated device's own loopback interface.
Instead you have to use the IP-address of the server when you open the socket.
pirko
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Apr 08, 2011 1:19 pm

Re: how can emulator access my server

Postby raj_J2ME » Thu May 05, 2011 6:36 am

What error are you getting while accessing the server?

You check this URL, this will help you,
http://www.anddev.org/socket_programming-t325.html
Thanks with Regards,
Raj - The Kernel
raj_J2ME
Master Developer
Master Developer
 
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 2 guests