1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| public class Threa implements Runnable
{
public static final String SERVERIP = "192.168.1.4";
public static final int SERVERPORT =6060 ; //4444
public int x=0;
public void run() {
try {
Log.i("------Connect--------", "------------1-------------");
// System.out.println("S: Connecting...");
ServerSocket serverSocket = new ServerSocket(SERVERPORT);
Log.i("------xxxxxxxxx--------", "------------2-------------");
while (true) {
x++;
Log.i("------xxxxxxxxxx--------","-----------"+x+"-----------");
Log.i("------xxxxxxxxxx--------", "-----------pret de listener------------");
Socket client = serverSocket.accept();
Log.i("------xxxxxxxxxx--------", "-----------en cours de listening-------------");
try {
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
String str = in.readLine();
Log.i("------xxxxxxxxxx--------", str + "-------------");
//System.out.println("S: Received: '" +);
} catch(Exception e) {
Log.i("------xxxxxxxxxx--------", "S: Error");
} finally {
client.close();
Log.i("------xxxxxxxxxx--------","S: Done.");
}
}
} catch (Exception e) {
Log.i("------xxxxxxxxxx--------","S: Error");
}
}
} |
Partager