All pastes #192993 Raw Edit

7 moi

public text v1 · immutable
·published 2006-10-06 13:06 UTC
rendered paste body
public class Serveur{
    private Vector clients;
    private int port;
    private ServerSocket socEcoute;
    
    
    public Serveur(int port) throws IOException {
        this.clients = new Vector();
        this.port = port;
        System.out.println("# -->Creation du Serveur sur le port "+this.port);
        this.socEcoute = new ServerSocket(this.port);
        System.out.println("# -->Serveur Ouvert !");
        //this.socEcoute.setSoTimeout(200);
        Clients tmp;
        while(true){
            tmp = new Clients(this.socEcoute.accept());
            tmp.start();
            this.ajouterClient(tmp);
        }
        
    }
    
    private synchronized void ajouterClient(Clients tmp) {
        this.clients.addElement(tmp);
    }
    
}