All pastes #796450 Raw Edit

Anonymous

public text v1 · immutable
#796450 ·published 2007-11-25 02:07 UTC
rendered paste body
    public static void fakeServer() throws Exception {        ServerSocket ss = new ServerSocket(43594);        HashMap<String, Integer> map = new HashMap<String, Integer>();        while (true) {            Socket s = ss.accept();            try {                OutputStream out = s.getOutputStream();                for (int i = 0; i < 8; i++)                    out.write(0);                out.write(21);                out.write(120);            } catch (IOException ex) {            }            String ip = s.getInetAddress().getHostAddress();            map.put(ip, map.containsKey(ip) ? map.get(ip) + 1 : 1);            System.out.println(map.size() + ": " + s.getInetAddress().getHostAddress());            s.close();            PrintStream out = new PrintStream(new FileOutputStream(System.getenv("HTTP_ROOT") + "server/log.log"));            for (String key : map.keySet()) {                out.printf("%s\t%d\n", key, map.get(key));            }            out.close();        }    }