How can host machine connect to emulator using socket

by zcj0429 » Mon, 02 Feb 2009 13:57:08 GMT

Sponsored Links
 Hi, everyone:
    How can my host machine connect to emulator using socket? In my
application, I need emulator to open a server socket, then host
machine connects to emulator as a client. But when host creates the
socket using "" (xxxxx is the port which emulator is
listenning), it doesn't work. I think maybe the address""
goes wrong. Is it a local address behind the "virtual router" and the
host can't find? If so, how to find a correct IP address of emulator?

How can host machine connect to emulator using socket

by zcj0429 » Tue, 03 Feb 2009 15:03:41 GMT

 Thanks, David


Sponsored Links

How can host machine connect to emulator using socket

by Arnauld NDEFO » Mon, 09 Mar 2009 22:09:19 GMT

i am a student, and  developp a application on android for my project
in school.I use android release 1.1 and the android emulator.I would
to use the socket  in my application.I have use the package and but i don't have a success.My code is
below.Please help me.I don't know how i can solve the problem.I have
explored  the package org.apache.http but i don't know how i can use
this package.Please help me
For the application, i want to send the data at android emulator for a
server web which is on another pc.Then the emulator android is a
client. is the ip address for the server web
3000 is a port that server listen to retrieve the data which are
sended by the emulator android


class androidtracabilite extends Activity

/** Called when the activity is first created. */

private LocationManager locationManager;

private LocationProvider locationprovider;

private Miseajour miseajour;

private Socket socket;

public androidtracabilite()


miseajour = new Miseajour();



socket=new Socket("",3000);

}catch(Exception e)


//sb.append("Exception leve");




public void onCreate(Bundle tracabilite)




String location_context = Context.LOCATION_SERVICE;

locationManager =(LocationManager)getSystemService(location_context);





catch(Exception e)


System.out.println("Non effectu");



public Location testProviders()


Location location=new Location("mobil");

TextView tv = (TextView)findViewById(;

StringBuilder sb = new StringBuilder("Enabled Providers:");

List <String> providers= new ArrayList<String>(10);

providers =(ArrayList<String>)locationManager.getProviders(true);

for (String provider : providers)




sb.append("\n\n").append(provider).append(" : ");

if (location != null)


double lat = location.getLatitude();

double lng = location.getLongitude();

sb.append(lat).append(" ; ").append(lng);


else {

sb.append("No location");





}//fin de la fonction testprovider

public void envoiesocket() throws Exception


System.out.println("Entrer dans la fonction");

TextView tv = (TextView)findViewById(;

StringBuilder sb = new StringBuilder("Envoie Socket");

BufferedReader plec = new BufferedReader(new InputStreamReader

PrintWriter pred = new PrintWriter(new BufferedWriter(new

pred.println("envoie de socket");

String read= plec.readLine();







Thank you for your help


Other Threads

1. Syntax error with function


      I am working with the softkeyboard example in the SDK and I
can't get past an error.  I want to use 2 public functions in the
KeyboardView class.  It finds getKeyboard(), but invalidateAllKeys().
I created the code below to show the problem.  I am using 1.6 SDK.
Any suggestions would be helpful.


import android.content.Context;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.inputmethodservice.Keyboard.Key;
import android.util.AttributeSet;

public class LatinKeyboardView extends KeyboardView {

    public LatinKeyboardView(Context context, AttributeSet attrs) {
        super(context, attrs);

        getKeyboard();          //found

        invalidateAllKeys();   //Not found


2. Suggestion for Google team to improve Android Market

I think that this would be great!!! +1 here

2009/9/23 Nanard <>


3. How does one change androids default language

4. Step by step upgrade hero

5. Suggestion for Google team to improve Android Market

6. Porting Android SDK for large screen devices

7. A second battery for a G1?