/** * Initialize a server on the given port. This server will not listen until it is launched with * the start() method. * * @param port * @throws IOException */ public Server(int port, int botPort, Retriever ret, Map<String, Double> traffic) throws IOException { if (port <= 1024 || botPort <= 1024) { throw new IllegalArgumentException("Ports under 1024 are reserved!"); } _port = port; _clients = new ClientPool(); _socket = new ServerSocket(port); try { _botSocket = new Socket("localhost", botPort); _botConnectionSuccess = true; _trafficInput = new BufferedReader(new InputStreamReader(_botSocket.getInputStream())); _trafficData = traffic; } catch (ConnectException e) { System.out.println("unable to connect"); System.out.println(e.getMessage()); _botConnectionSuccess = false; } r = ret; }