Hi :),
Here is the main code of the client:
try {
Socket socket = new Socket("10.0.2.2",port);
// System.out.println("SOCKET = " + socket);
BufferedReader plec = new BufferedReader(
new
InputStreamReader(socket.getInputStream())
);
PrintWriter pred = new PrintWriter(
new BufferedWriter(
new
OutputStreamWriter(socket.getOutputStream())),
true);
String str = "bonjour";
for (int i = 0; i < 5; i++) {
pred.println(str); // envoi d'un message
str = plec.readLine();
tv.append(str);// lecture de l'écho
try{
Thread.sleep(1000);
}catch (InterruptedException e){
}
}
// System.out.println("END"); // message de terminaison
pred.println("END") ;
plec.close();
pred.close();
socket.close();
}
catch (IOException e){
e.printStackTrace();
}
Try with IP adress maybe it cannot solve "en3rgizer", "10.0.2.2" is
the adress given by the emulator for your computor (because the
localhost for the emulator is the emulator) and you need to have a
server app which is listenning.
For the rest I solve my problem, to communicate within two emulators
you have to connect with the consol of one of the emulator and type
"redir add tcp:portComputer:portEmulator" then all the data arriving
on the port "portComputer" of your computer will be send to the
virtual port "portEmulator" of the emulator. So if the emulator is
listenning on the port "portEmulator" then you can connect with
another emulator by connecting on the "portComputer". I dont really
know if I made myself clear, sorry for my english :).
see u
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---