/** * Create a {@link TlsAddress} from a {@link TcpAddress}. * @param tcpAddress * the {@link TcpAddress} for the new {@link TlsAddress}. * @since 3.0.5 */ public TlsAddress(TcpAddress tcpAddress) { super(tcpAddress.getInetAddress(), tcpAddress.getPort()); }
@Override public TcpAddress getListenAddress() { int port = tcpAddress.getPort(); ServerThread serverThreadCopy = serverThread; try { port = serverThreadCopy.ssc.socket().getLocalPort(); } catch (NullPointerException npe) { // ignore } return new TcpAddress(tcpAddress.getInetAddress(), port); }
public ServerThread() throws IOException, NoSuchAlgorithmException { // Selector for incoming requests selector = Selector.open(); if (serverEnabled) { // Create a new server socket and set to non blocking mode ssc = ServerSocketChannel.open(); ssc.configureBlocking(false); // Bind the server socket InetSocketAddress isa = new InetSocketAddress(tcpAddress.getInetAddress(), tcpAddress.getPort()); setSocketOptions(ssc.socket()); ssc.socket().bind(isa); // Register accepts on the server socket with the selector. This // step tells the selector that the socket wants to be put on the // ready list when accept operations occur, so allowing multiplexed // non-blocking I/O to take place. ssc.register(selector, SelectionKey.OP_ACCEPT); } }
public ServerThread() throws IOException, NoSuchAlgorithmException { super(TLSTM.this); // Selector for incoming requests if (serverEnabled) { // Create a new server socket and set to non blocking mode ssc = ServerSocketChannel.open(); ssc.configureBlocking(false); // Bind the server socket InetSocketAddress isa = new InetSocketAddress(tcpAddress.getInetAddress(), tcpAddress.getPort()); setSocketOptions(ssc.socket()); ssc.socket().bind(isa); // Register accepts on the server socket with the selector. This // step tells the selector that the socket wants to be put on the // ready list when accept operations occur, so allowing multiplexed // non-blocking I/O to take place. ssc.register(selector, SelectionKey.OP_ACCEPT); } }
public ServerThread() throws IOException { buf = new byte[getMaxInboundMessageSize()]; // Selector for incoming requests selector = Selector.open(); if (serverEnabled) { // Create a new server socket and set to non blocking mode ssc = ServerSocketChannel.open(); ssc.configureBlocking(false); // Bind the server socket InetSocketAddress isa = new InetSocketAddress(tcpAddress.getInetAddress(), tcpAddress.getPort()); setSocketOptions(ssc.socket()); ssc.socket().bind(isa); // Register accepts on the server socket with the selector. This // step tells the selector that the socket wants to be put on the // ready list when accept operations occur, so allowing multiplexed // non-blocking I/O to take place. ssc.register(selector, SelectionKey.OP_ACCEPT); } }
@Override public TcpAddress getListenAddress() { int port = tcpAddress.getPort(); ServerThread serverThreadCopy = serverThread; try { port = ((InetSocketAddress) serverThreadCopy.ssc.getLocalAddress()).getPort(); } catch (NullPointerException npe) { // ignore } catch (IOException e) { e.printStackTrace(); } return new TcpAddress(tcpAddress.getInetAddress(), port); }
@Override public TcpAddress getListenAddress() { int port = tcpAddress.getPort(); ServerThread serverThreadCopy = serverThread; try { port = ((InetSocketAddress)serverThreadCopy.ssc.getLocalAddress()).getPort(); } catch (NullPointerException npe) { // ignore } catch (IOException e) { e.printStackTrace(); } return new TcpAddress(tcpAddress.getInetAddress(), port); }
@Override public TcpAddress getListenAddress() { int port = tcpAddress.getPort(); ServerThread serverThreadCopy = serverThread; try { port = serverThreadCopy.ssc.socket().getLocalPort(); } catch (NullPointerException npe) { if (logger.isDebugEnabled()) { logger.debug("TLSTM.getListenAddress called but TLSTM is not listening yet"); } } return new TcpAddress(tcpAddress.getInetAddress(), port); }
tcpAddress.getPort()); setSocketOptions(ssc.socket()); ssc.socket().bind(isa);
tcpAddress.getPort()); setSocketOptions(ssc.socket()); ssc.socket().bind(isa);
public SocketEntry(TcpAddress address, Socket socket, boolean useClientMode, TransportStateReference tmStateReference) throws NoSuchAlgorithmException { this.inAppBuffer = ByteBuffer.allocate(getMaxInboundMessageSize()); this.inNetBuffer = ByteBuffer.allocate(getMaxInboundMessageSize()); this.outNetBuffer = ByteBuffer.allocate(getMaxInboundMessageSize()); this.peerAddress = address; this.tmStateReference = tmStateReference; this.socket = socket; this.lastUse = System.nanoTime(); if (tmStateReference == null) { counterSupport.fireIncrementCounter(new CounterEvent(this, SnmpConstants.snmpTlstmSessionAccepts)); } SSLContext sslContext = sslEngineConfigurator.getSSLContext(useClientMode, tmStateReference); this.sslEngine = sslContext.createSSLEngine(address.getInetAddress().getHostName(), address.getPort()); sslEngine.setUseClientMode(useClientMode); // sslEngineConfigurator.configure(SSLContext.getDefault(), useClientMode); sslEngineConfigurator.configure(sslEngine); synchronized (TLSTM.this) { sessionID = nextSessionID++; } }
public SocketEntry(TcpAddress address, Socket socket, boolean useClientMode, TransportStateReference tmStateReference) throws NoSuchAlgorithmException { super(address, socket); this.inAppBuffer = ByteBuffer.allocate(getMaxInboundMessageSize()); this.inNetBuffer = ByteBuffer.allocate(getMaxInboundMessageSize()); this.outNetBuffer = ByteBuffer.allocate(getMaxInboundMessageSize()); this.tmStateReference = tmStateReference; if (tmStateReference == null) { counterSupport.fireIncrementCounter(new CounterEvent(this, SnmpConstants.snmpTlstmSessionAccepts)); } SSLEngineConfigurator sslEngineConfigurator = ensureSslEngineConfigurator(); SSLContext sslContext = sslEngineConfigurator.getSSLContext(useClientMode, tmStateReference); this.sslEngine = sslContext.createSSLEngine(address.getInetAddress().getHostName(), address.getPort()); sslEngine.setUseClientMode(useClientMode); sslEngineConfigurator.configure(sslEngine); synchronized (TLSTM.this) { sessionID = nextSessionID++; } }
InetSocketAddress targetAddress = new InetSocketAddress(((TcpAddress)address).getInetAddress(), ((TcpAddress)address).getPort()); if ((s == null) || (s.isClosed())) {
InetSocketAddress targetAddress = new InetSocketAddress(((TcpAddress) address).getInetAddress(), ((TcpAddress) address).getPort()); if ((s == null) || (s.isClosed())) {
InetSocketAddress targetAddress = new InetSocketAddress(((TcpAddress)address).getInetAddress(), ((TcpAddress)address).getPort()); if ((s == null) || (s.isClosed())) {
InetSocketAddress targetAddress = new InetSocketAddress(((TcpAddress) address).getInetAddress(), ((TcpAddress) address).getPort()); if ((s == null) || (s.isClosed())) {
InetSocketAddress targetAddress = new InetSocketAddress(((TcpAddress)address).getInetAddress(), ((TcpAddress)address).getPort()); if ((s == null) || (s.isClosed())) {