//
import java.io.*;
import java.net.*;
import java.util.*;
public class Serveur2 extends Thread {
protected static final int PORT=45678;
protected ServerSocket ecoute;
protected Vector connexions;
protected Nettoyeur nettoyeur;
public Serveur2 ()
{ try
{ecoute=new ServerSocket(PORT);}
catch (IOException e)
{System.err.println(e.getMessage());
System.exit(1);
}
System.out.println("Serveur en ecoute sur le port :"+PORT);
connexions=new Vector();
nettoyeur=new Nettoyeur(this);
this.start();
}
public void run()
{ try
{while (true)
{Socket client=ecoute.accept();
System.out.println("Demande de connexion...");
Connexion2 c= new Connexion2(client,nettoyeur,this);
synchronized (connexions) {connexions.addElement(c);}
}}
catch (IOException e)
{System.err.println(e.getMessage());
System.exit(1);
}
}
public static void main(String[] args)
{new Serveur2();
}
}