/** * 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.");
/** * 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()); }