Basically what I want to achieve is have a server running on an
android device that a P.C/Laptop/whatever can connect to using
sockets.
Currently I have this working on an emulator, where I can send a
simple text String, but obviously networking on a real divice is
different.
I was just wondering what changes to my code I would have to make to
get this to work a real device?
Here is the code which works on the emulator. Thanks in advance
<<<Android Server>>>
public void run() {
try {
ss = new ServerSocket(1234);
}
catch(IOException e) {
System.out.print(e);
System.exit(1);
}
while (true) {
try {
socket = ss.accept();
in = new BufferedReader(
new InputStreamReader(
socket.getInputStream
()));
String text = in.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
<<<Development Machine Client>>>
public TestClient() {
try {
socket = new Socket("127.0.0.1", 1234);
out = new PrintWriter(socket.getOutputStream(), true);
out.println("TEST");
}
catch (UnknownHostException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---