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); } } public class Clients extends Thread { private Socket soc; private BufferedReader lecture; private PrintWriter ecriture; public Clients(Socket soc) throws IOException{ this.soc = soc; this.lecture = new BufferedReader( new InputStreamReader(soc.getInputStream()) ); this.ecriture = new PrintWriter( new BufferedWriter( new OutputStreamWriter(soc.getOutputStream())) ,true); } /* (non-Javadoc) * @see java.lang.Runnable#run() */ public void run() { // Ecoute du client par la socket ... }