import java.net.*; import java.io.*; public class Client extends Thread { private Socket s = null; private PrintWriter out = null; private BufferedReader in = null; private Tunnel t = null; private static String sHost = "atlas.dsv.su.se"; private static String sPort = "9449"; private static String mAddress = "234.235.236.237"; private static String mPort = "2000"; private static String mTTL = "1"; private static String dAddress = "atlas.dsv.su.se"; private static String dPort = "2222"; private static String addressServer = "atlas.dsv.su.se"; private boolean showActions = true; private boolean active = true; public static void main(String args[]) { if(args.length != 0) { mAddress = args[0]; if(args.length != 1) { mPort = args[1]; if(args.length != 2) { mTTL = args[2]; } } } new Client(); } public Client() { start(); } public void run() { try { s = new Socket(sHost, Integer.parseInt(sPort)); System.out.println("CONNECTED TO: " + sHost + " - ON PORT: " + sPort); in = new BufferedReader(new InputStreamReader(s.getInputStream())); out = new PrintWriter(s.getOutputStream(), true); out.println(mAddress + ":" + mPort + ":" + mTTL); } catch (Exception e) { System.out.println("COULD NOT CONNECT: " + e); killMe(); } t = new Tunnel(mAddress, mPort, mTTL, dAddress, dPort, addressServer, showActions); String inputLine = ""; while(active) { try { inputLine = in.readLine(); } catch(Exception e) { e.printStackTrace(); } } } private void killMe() { active = false; try { out.close(); in.close(); s.close(); } catch(Exception e) { e.printStackTrace(); } t.stopTunnel(); System.exit(1); } }