import java.io.*; import java.net.*; public class MiniServidor { public static void main (String args[]) { try{ ServerSocket s = new ServerSocket(Integer.parseInt(args[0])); ArraySocket as= new ArraySocket(); for (int i=0; i<3; i++) { Socket cs= s.accept(); as.add(cs); Client client = new Client(cs, as); client.start(); } s.close(); } catch (Exception e) { e.printStackTrace(); } } } class ArraySocket { Socket sockets[]; int lastSocket; public ArraySocket (){ sockets= new Socket[3]; lastSocket=0; } public synchronized void add (Socket s){ sockets[lastSocket++]=s; } public synchronized void send (String str, Socket excluir){ System.out.println(excluir.getInetAddress().getHostAddress()+":"+ excluir.getPort()+" "+str); try { for (int i=0; i< lastSocket; i++) if (sockets[i]!=excluir) new PrintWriter(sockets[i].getOutputStream(), true).println(str); } catch (Exception e) { e.printStackTrace(); } } public synchronized void remove(Socket s){ // esta implementación no se pedía int i; for (i=0; sockets[i]!=s && i