/** * This is used to close all the listeners that have been * added to the connection. Closing all the listeners in the * set ensures that there are no lingering threads or sockets * consumed by the connection after the connection is closed. * * @throws IOException thrown if there is an error closing */ public void close() throws IOException { for(Closeable listener : this) { listener.close(); } if(agent != null) { agent.stop(); } clear(); } }