/** * Constructor for the <code>SocketConnection</code> object. This * will create a new connection that accepts incoming connections * and hands these connections as <code>Pipeline</code> objects * to the specified processor. This in turn will deliver request * and response objects to the internal container. * * @param server this is the processor that receives requests * @param agent this is used to create a trace for the socket */ public SocketConnection(Server server, Agent agent) throws IOException { this.manager = new SocketListenerManager(server, agent); this.server = server; }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal socket connector. * * @param address this is the address used to accept connections * * @return this returns the actual local address that is used */ public SocketAddress listen(SocketAddress address) throws IOException { return listen(address, null); }
/** * This is used to close the connection and the server socket * used to accept connections. This will perform a close of all * connected server sockets that have been created from using * the <code>connect</code> method. The connection can be * reused after the existing server sockets have been closed. * * @throws IOException thrown if there is a problem closing */ public void close() throws IOException { if(!closed) { manager.close(); processor.stop(); } closed = true; } }
/** * 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(); } }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal <code>Server</code> implementation as a pipeline. The * background task is a non daemon task to ensure the server is * kept active, to terminate the connection this can be closed. * * @param address this is the address used to accept connections * @param context this is used for secure SSL connections * * @return this returns the actual local address that is used */ public SocketAddress listen(SocketAddress address, SSLContext context) throws IOException { SocketListener listener = new SocketListener(address, context, server, agent); if(server != null) { add(listener); } return listener.getAddress(); }
/** * This is used to close the connection and the server socket * used to accept connections. This will perform a close of all * connected server sockets that have been created from using * the <code>connect</code> method. The connection can be * reused after the existing server sockets have been closed. * * @throws IOException thrown if there is a problem closing */ public void close() throws IOException { if(!closed) { manager.close(); processor.stop(); } closed = true; } }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal <code>Server</code> implementation as a pipeline. The * background task is a non daemon task to ensure the server is * kept active, to terminate the connection this can be closed. * * @param address this is the address used to accept connections * * @return this returns the actual local address that is used */ public SocketAddress listen(SocketAddress address) throws IOException { return listen(address, null); }
/** * Constructor for the <code>SocketConnection</code> object. This * will create a new connection that accepts incoming connections * and hands these connections as <code>Socket</code> objects * to the specified processor. This in turn will deliver request * and response objects to the internal container. * * @param processor this is the connector that receives requests * @param analyzer this is used to create a trace for the socket */ public SocketConnection(SocketProcessor processor, TraceAnalyzer analyzer) throws IOException { this.manager = new SocketListenerManager(processor, analyzer); this.processor = processor; }
/** * This is used to close the connection and the server socket * used to accept connections. This will perform a close of all * connected server sockets that have been created from using * the <code>connect</code> method. The connection can be * reused after the existing server sockets have been closed. * * @throws IOException thrown if there is a problem closing */ public void close() throws IOException { if(!closed) { manager.close(); server.stop(); } closed = true; } }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal socket connector. * * @param address this is the address used to accept connections * * @return this returns the actual local address that is used */ public SocketAddress listen(SocketAddress address) throws IOException { return listen(address, null); }
/** * Constructor for the <code>SocketConnection</code> object. This * will create a new connection that accepts incoming connections * and hands these connections as <code>Socket</code> objects * to the specified processor. This in turn will deliver request * and response objects to the internal container. * * @param processor this is the connector that receives requests * @param analyzer this is used to create a trace for the socket */ public SocketConnection(SocketProcessor processor, TraceAnalyzer analyzer) throws IOException { this.manager = new SocketListenerManager(processor, analyzer); this.processor = processor; }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal socket connector. * * @param address this is the address used to accept connections * * @return this returns the actual local address that is used */ public SocketAddress connect(SocketAddress address) throws IOException { if(closed) { throw new ConnectionException("Connection is closed"); } return manager.listen(address); }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal socket connector. * * @param address this is the address used to accept connections * * @return this returns the actual local address that is used */ public SocketAddress connect(SocketAddress address) throws IOException { if(closed) { throw new ConnectionException("Connection is closed"); } return manager.listen(address); }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal socket connector. * * @param address this is the address used to accept connections * @param context this is used for secure SSL connections * * @return this returns the actual local address that is used */ public SocketAddress connect(SocketAddress address, SSLContext context) throws IOException { if(closed) { throw new ConnectionException("Connection is closed"); } return manager.listen(address, context); }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal socket connector. * * @param address this is the address used to accept connections * @param context this is used for secure SSL connections * * @return this returns the actual local address that is used */ public SocketAddress connect(SocketAddress address, SSLContext context) throws IOException { if(closed) { throw new ConnectionException("Connection is closed"); } return manager.listen(address, context); }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal <code>Server</code> implementation as a pipeline. The * background task is a non daemon task to ensure the server is * kept active, to terminate the connection this can be closed. * * @param address this is the address used to accept connections * * @return this returns the actual local address that is used */ public SocketAddress connect(SocketAddress address) throws IOException { if(closed) { throw new ConnectionException("Connection is closed"); } return manager.listen(address); }
/** * This creates a new background task that will listen to the * specified <code>ServerAddress</code> for incoming TCP connect * requests. When an connection is accepted it is handed to the * internal <code>Server</code> implementation as a pipeline. The * background task is a non daemon task to ensure the server is * kept active, to terminate the connection this can be closed. * * @param address this is the address used to accept connections * @param context this is used for secure SSL connections * * @return this returns the actual local address that is used */ public SocketAddress connect(SocketAddress address, SSLContext context) throws IOException { if(closed) { throw new ConnectionException("Connection is closed"); } return manager.listen(address, context); }