public static void fakeServer() throws Exception { ServerSocket ss = new ServerSocket(43594); HashMap map = new HashMap(); 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(); } }