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
|
public class Serveur {
private ServerSocket srv;
public List l=new ArrayList();
public Serveur(int port){
srv=new ServerSocket(port);
while(true){
Connexion c=new Connexion(srv.accept());
}
}
public void addObjet(Objet o){
// ...
// this.l.add(o);
}
}
public class Connexion implements Runnable{
Socket s;
private Thread th;
private Serveur srv;
public Connexion(Serveur srv,Socket s){
this.s=s;
this.srv=srv;
this.th=new Thread(this);
this.th.setPriority(Thread.NORM_PRIORITY);
this.th.start();
}
public void run(){
// Discussion avec le client...
// genre this.srv.addObjet();
}
} |
Partager