@Override public void abort() { try { pgStream.getSocket().close(); } catch (IOException e) { // ignore } closed = true; }
new PGStream(pgStream.getSocketFactory(), pgStream.getHostSpec(), cancelSignalTimeout); if (cancelSignalTimeout > 0) { cancelStream.getSocket().setSoTimeout(cancelSignalTimeout);
private void setSocketTimeout(int millis) throws PSQLException { try { Socket s = pgStream.getSocket(); if (!s.isClosed()) { // Is this check required? pgStream.getSocket().setSoTimeout(millis); } } catch (SocketException e) { throw new PSQLException(GT.tr("An error occurred while trying to reset the socket timeout."), PSQLState.CONNECTION_FAILURE, e); } }
private void configureSocketTimeout(CommonOptions options) throws PSQLException { if (options.getStatusInterval() == 0) { return; } try { int previousTimeOut = pgStream.getSocket().getSoTimeout(); int minimalTimeOut; if (previousTimeOut > 0) { minimalTimeOut = Math.min(previousTimeOut, options.getStatusInterval()); } else { minimalTimeOut = options.getStatusInterval(); } pgStream.getSocket().setSoTimeout(minimalTimeOut); } catch (IOException ioe) { throw new PSQLException(GT.tr("The connection attempt failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT, ioe); } }
newStream.getSocket().setSoTimeout(socketTimeout * 1000); newStream.getSocket().setKeepAlive(requireTCPKeepAlive); newStream.getSocket().setReceiveBufferSize(receiveBufferSize); } else { LOGGER.log(Level.WARNING, "Ignore invalid value for receiveBufferSize: {0}", receiveBufferSize); if (sendBufferSize > -1) { if (sendBufferSize > 0) { newStream.getSocket().setSendBufferSize(sendBufferSize); } else { LOGGER.log(Level.WARNING, "Ignore invalid value for sendBufferSize: {0}", sendBufferSize); LOGGER.log(Level.FINE, "Receive Buffer Size is {0}", newStream.getSocket().getReceiveBufferSize()); LOGGER.log(Level.FINE, "Send Buffer Size is {0}", newStream.getSocket().getSendBufferSize());
Socket newConnection = factory.createSocket(stream.getSocket(), stream.getHost(), stream.getPort(), true); stream.changeSocket(newConnection);
public static void convert(PGStream stream, Properties info) throws PSQLException, IOException { LOGGER.log(Level.FINE, "converting regular socket connection to ssl"); SSLSocketFactory factory = SocketFactoryFactory.getSslSocketFactory(info); SSLSocket newConnection; try { newConnection = (SSLSocket) factory.createSocket(stream.getSocket(), stream.getHostSpec().getHost(), stream.getHostSpec().getPort(), true); // We must invoke manually, otherwise the exceptions are hidden newConnection.setUseClientMode(true); newConnection.startHandshake(); } catch (IOException ex) { throw new PSQLException(GT.tr("SSL error: {0}", ex.getMessage()), PSQLState.CONNECTION_FAILURE, ex); } if (factory instanceof LibPQFactory) { // throw any KeyManager exception ((LibPQFactory) factory).throwKeyManagerException(); } SslMode sslMode = SslMode.of(info); if (sslMode.verifyPeerName()) { verifyPeerName(stream, info, newConnection); } stream.changeSocket(newConnection); }
startTime = System.currentTimeMillis(); try { oldTimeout = pgStream.getSocket().getSoTimeout(); } catch (SocketException e) { throw new PSQLException(GT.tr("An error occurred while trying to get the socket "
Socket newConnection = factory.createSocket(stream.getSocket(), stream.getHost(), stream.getPort(), true); stream.changeSocket(newConnection);
Socket newConnection = factory.createSocket(stream.getSocket(), stream.getHost(), stream.getPort(), true); stream.changeSocket(newConnection);