import java.io.*; import java.net.*; import java.util.Vector; public class SyrrServer { public static void main(String argumendid[]) throws IOException { ServerSocket ss = new ServerSocket(6001); Vector uhendused = new Vector(); while(true) { Socket sc = ss.accept(); uhendused.add(sc); new JututoaLoim(sc, uhendused); } } } class JututoaLoim extends Thread { static int count; Vector v; Socket sc; public JututoaLoim(Socket uus_sc, Vector uus_v) { v = uus_v; sc = uus_sc; start(); } public void run() { try { count++; BufferedReader sisse = new BufferedReader(new InputStreamReader(sc.getInputStream())); boolean veel = true; while(veel) { String rida = sisse.readLine(); System.out.println(rida); if(rida.startsWith(".ots")) { veel=false; } for(int i = 0; i < v.size(); i++) { Socket skt = (Socket)v.elementAt(i); PrintWriter valja = new PrintWriter(skt.getOutputStream(), true); valja.println(rida); } } sc.close(); } catch(Exception e) { System.out.println("Probleem: "+e); } v.remove(sc); } }