@Override protected SnappyTSSLSocket acceptImpl() throws TTransportException { try { Socket srvSock = this.serverSocket.accept(); return new SnappyTSSLSocket(srvSock, this.socketParams); } catch (IOException ioe) { throw new TTransportException(ioe); } }
/** * Creates a new unconnected SSL socket that will connect to the given host on * the given port. * * @param hostAddress Resolved remote host address * @param port Remote port * @param timeout Socket timeout * @param params Socket parameters including SSL properties */ public SnappyTSSLSocket(InetAddress hostAddress, int port, int timeout, SocketParameters params) throws TTransportException { super(initSSLSocket(hostAddress, port, params, timeout)); this.hostAddress = hostAddress; this.port = port; final Socket socket = getSocket(); setProperties(socket, timeout, params); if (!isOpen()) { this.open(); } this.socketToSameHost = ClientSharedUtils.isSocketToSameHost( socket.getLocalSocketAddress(), socket.getRemoteSocketAddress()); }
/** * Constructor that takes an already created socket. * * @param socket Already created socket object * @throws TTransportException if there is an error setting up the streams */ public SnappyTSSLSocket(Socket socket, SocketParameters params) throws TTransportException { super(socket); this.socketToSameHost = ClientSharedUtils.isSocketToSameHost( socket.getLocalSocketAddress(), socket.getRemoteSocketAddress()); if (isOpen()) { try { setProperties(socket, params.getReadTimeout(), params); this.inputStream_ = new BufferedInputStream(socket.getInputStream(), this.inputBufferSize); this.outputStream_ = new BufferedOutputStream(socket.getOutputStream(), this.outputBufferSize); } catch (IOException ioe) { close(); throw new TTransportException(TTransportException.NOT_OPEN, ioe); } } }
if (isOpen()) { throw new TTransportException(TTransportException.ALREADY_OPEN, "Socket already connected."); final Socket socket = getSocket(); try { socket.connect(new InetSocketAddress(this.hostAddress, this.port), this.outputBufferSize); } catch (IOException ioe) { close(); throw new TTransportException(TTransportException.NOT_OPEN, ioe);
/** * {@inheritDoc} */ @Override public int getSoTimeout() throws SocketException { return getSocket().getSoTimeout(); }
/** * Sets the socket read timeout. * * @param timeout read timeout (SO_TIMEOUT) in milliseconds */ @Override public void setSoTimeout(int timeout) throws SocketException { getSocket().setSoTimeout(timeout); this.timeout = timeout; }
transport = new SnappyTSSLSocket(controlAddr, this.socketParams); } else { transport = new SnappyTSocket(controlAddr, null, false, true,
/** * Sets the socket read timeout. * * @param timeout read timeout (SO_TIMEOUT) in milliseconds */ @Override public void setTimeout(int timeout) { try { getSocket().setSoTimeout(timeout); this.timeout = timeout; } catch (SocketException se) { LOGGER.warn("Could not set socket timeout.", se); } }
final TTransport transport; if (getServerType().isThriftSSL()) { transport = new SnappyTSSLSocket(hostAddr.resolveHost(), hostAddr.getPort(), readTimeout, socketParams); } else {