import java.io.*; import java.net.*; import java.util.*; import java.awt.*; import java.awt.event.*; public class vorkT{ public static void main(String argumendid[]) throws IOException{ int nr=1; Vector uhendused=new Vector(); ServerSocket ss=new ServerSocket(3001); while(true){ Socket sc=ss.accept(); uhendused.add(sc); new vorkloim(sc, nr, uhendused); nr++; } } } class vorkloim extends Thread implements ActionListener{ Socket sc; PrintWriter valja; TextField tf; Vector v; int nr; public vorkloim(Socket uus_sc, int uus_nr, Vector t){ v=t; sc=uus_sc; nr=uus_nr; start(); } public void actionPerformed(ActionEvent e){ try{ valja.println("Message from root: "+tf.getText()); tf.setText(""); tf.requestFocus(); }catch(Exception viga){viga.printStackTrace();} } public void run(){ try{ valja=new PrintWriter(sc.getOutputStream(), true); BufferedReader sisse=new BufferedReader( new InputStreamReader(sc.getInputStream()) ); Frame raam = new Frame(""+sc.getInetAddress()); raam.setLayout(new BorderLayout()); tf=new TextField(); tf.addActionListener(this); TextArea ta=new TextArea(); ta.setSize(25,80); raam.add("North", tf); raam.add("Center", ta); raam.setSize(400, 500); raam.show(); valja.println("Mis su nimi on?"); String nimi=sisse.readLine(); if(true) { valja.println("Edukas sisselogimine"); } else{ valja.println("Kahjuks sisselogimine ebaõnnestus"); sc.close(); System.out.println("Minema siit!!"); throw new Exception("Jama nimedega"); } Thread.sleep(5000); ta.setText("Sisse logis kasutaja " +nimi+ " masinast " +sc.getInetAddress()+" , sinu järjekorra number on " +nr); PrintWriter kirjuta=new PrintWriter( new FileWriter(nimi+ ".txt")); kirjuta.println("Külalise nimi: "+nimi+"\r\n"+ "Külaline oli sisse logitud masinast: "+sc.getInetAddress()+"\r\n"+ "Aeg oli: " +new Date()); kirjuta.close(); String valju; do { System.out.println("iirutame veidi"); valju=sisse.readLine(); // for(int i=0; i