import java.io.*; import java.net.*; public class Tripsuserver{ static final int pordinr=3001; static final String masin="minitorn.tpu.ee"; static final String lopp=".ots"; public static void main(String argumendid[]) throws Exception{ ServerSocket ss=new ServerSocket(Tripsuserver.pordinr); while(true){ Socket sc1=ss.accept(); new PrintWriter(sc1.getOutputStream(), true).println(".margiksX "+ "Oota paarilist"); System.out.println("Esimene"); Socket sc2=ss.accept(); new PrintWriter(sc2.getOutputStream(), true).println(".margiks0"); System.out.println("Teine"); new Tripsuloim(sc1, sc2); } } } class Tripsuloim extends Thread{ Socket[] sc=new Socket[2]; public Tripsuloim(Socket usc1, Socket usc2){ sc[0]=usc1; sc[1]=usc2; start(); } public void run(){ try{ BufferedReader sisse[]=new BufferedReader[2]; PrintWriter valja[]=new PrintWriter[2]; for(int i=0; i<2; i++){ sisse[i]=new BufferedReader( new InputStreamReader(sc[i].getInputStream()) ); valja[i]=new PrintWriter(sc[i].getOutputStream(), true); } valja[0].println(".kaikVaba"); boolean veel=true; while(veel){ String vastus=sisse[0].readLine(); kirjuta(valja, vastus); if(!vastus.equals(Tripsuserver.lopp)){ vastus=sisse[1].readLine(); kirjuta(valja, vastus); } if(vastus.equals(Tripsuserver.lopp))veel=false; } for(int i=0; i<2; i++){ sc[i].close(); } }catch(Exception e){ System.out.println("Probleem:"+e); } } private void kirjuta(PrintWriter[] pw, String teade){ for(int i=0; i