private ByteChannel initChannel(String id, SelectionKey key, boolean ssl, SocketParameters params, boolean forClient) throws TTransportException, IOException { if (ssl) { // setup the SSL engine SSLEngine engine = SSLFactory.createEngine(this.socketAddress.getHostName(), this.socketAddress.getPort(), params, forClient); return SSLSocketChannel.create(id, socketChannel, key, engine, true); } else { return this.socketChannel; } }