@Override public int getSoTimeout() throws SocketException { return sock.getSoTimeout(); }
public int getSocketTimeout() { if (this.socket != null) { try { return this.socket.getSoTimeout(); } catch (SocketException ignore) { return -1; } } else { return -1; } }
public int getSocketTimeout() { if (this.socket != null) { try { return this.socket.getSoTimeout(); } catch (SocketException ignore) { return -1; } } else { return -1; } }
/** * @return the SO_TIMEOUT of the Socket that this client uses. 0 returns implies that the option is disabled (i.e., * timeout of infinity). * @throws SocketException if configuration failed */ public int getSoTimeout() throws SocketException { if (socket != null) { return socket.getSoTimeout(); } else { return 0; } }
public int getNetworkTimeout() throws IOException { return connection.getSoTimeout(); } }
@Override public int getReadTimeout() throws IOException { try { return this.socket.getSoTimeout(); } catch (SocketException e) { throw new IOException("Error on underlying Socket"); } }
@Override public int getSoTimeout() { try { return javaSocket.getSoTimeout(); } catch (IOException e) { throw new ChannelException(e); } }
/** * Returns socket timeout. * * @throws SQLException if there is an error in the underlying protocol. */ public int timeout() throws SQLException { try { return sock.getSoTimeout(); } catch (SocketException e) { throw new SQLException("Failed to set connection timeout.", SqlStateCode.INTERNAL_ERROR, e); } } }
@Override public int getSoTimeout() { try { return javaSocket.getSoTimeout(); } catch (IOException e) { throw new ChannelException(e); } }
/** * See {@link Socket#getSoTimeout()}. Calling this method does not trigger mode detection. */ @Override public synchronized int getSoTimeout() throws SocketException { return getSocketAllowUnknownMode().getSoTimeout(); }
public String getSocketString() { try { return String.valueOf(theSocket.getInetAddress()) + ':' + theSocket.getPort() + " timeout: " + theSocket.getSoTimeout(); } catch (Exception e) { return String.format("Error in getSocketString: %s", e.getLocalizedMessage()); } }
@Override public int getSoTimeout() { try { return javaSocket.getSoTimeout(); } catch (IOException e) { throw new ChannelException(e); } }
/** * Same as <code>getInputStream(socket, socket.getSoTimeout()).</code> * <br><br> * * @see #getInputStream(Socket, long) */ public static SocketInputWrapper getInputStream(Socket socket) throws IOException { return getInputStream(socket, socket.getSoTimeout()); }
/** * Same as SocketInputStream(socket.getChannel(), socket.getSoTimeout()) * :<br><br> * * Create a new input stream with the given timeout. If the timeout * is zero, it will be treated as infinite timeout. The socket's * channel will be configured to be non-blocking. * @see SocketInputStream#SocketInputStream(ReadableByteChannel, long) * * @param socket should have a channel associated with it. * @throws IOException */ public SocketInputStream(Socket socket) throws IOException { this(socket.getChannel(), socket.getSoTimeout()); }
/** Returns true if this connection is ready to host new streams. */ public boolean isHealthy(boolean doExtensiveChecks) { if (socket.isClosed() || socket.isInputShutdown() || socket.isOutputShutdown()) { return false; } if (http2Connection != null) { return !http2Connection.isShutdown(); } if (doExtensiveChecks) { try { int readTimeout = socket.getSoTimeout(); try { socket.setSoTimeout(1); if (source.exhausted()) { return false; // Stream is exhausted; socket is closed. } return true; } finally { socket.setSoTimeout(readTimeout); } } catch (SocketTimeoutException ignored) { // Read timed out; socket is good. } catch (IOException e) { return false; // Couldn't read; socket is closed. } } return true; }
/** Returns true if this connection is ready to host new streams. */ public boolean isHealthy(boolean doExtensiveChecks) { if (socket.isClosed() || socket.isInputShutdown() || socket.isOutputShutdown()) { return false; } if (http2Connection != null) { return !http2Connection.isShutdown(); } if (doExtensiveChecks) { try { int readTimeout = socket.getSoTimeout(); try { socket.setSoTimeout(1); if (source.exhausted()) { return false; // Stream is exhausted; socket is closed. } return true; } finally { socket.setSoTimeout(readTimeout); } } catch (SocketTimeoutException ignored) { // Read timed out; socket is good. } catch (IOException e) { return false; // Couldn't read; socket is closed. } } return true; }
/** * @param addr Remote address. * @param port Remote port. * @return Opened socket. * @throws IOException If failed. */ private Socket openSocket(InetAddress addr, int port) throws IOException { Socket sock = new Socket(); sock.bind(new InetSocketAddress(InetAddress.getByName("192.168.0.100"), 0)); sock.connect(new InetSocketAddress(addr, port), 1); X.println("Socket [timeout=" + sock.getSoTimeout() + ", linger=" + sock.getSoLinger() + ", sndBuf=" + sock.getSendBufferSize() + ", sndBuf=" + sock.getSendBufferSize() + ']'); return sock; } }
/** */ @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg, long timeout) throws IOException, IgniteCheckedException { if (writeToSocketDelay > 0) { try { U.dumpStack(log, "Before sleep [msg=" + msg + ']'); Thread.sleep(writeToSocketDelay); } catch (InterruptedException e) { // Nothing to do. } } if (sock.getSoTimeout() >= writeToSocketDelay) super.writeToSocket(sock, out, msg, timeout); else throw new SocketTimeoutException("Write to socket delay timeout exception."); }
@Override public void run() { try { byte[] buf = new byte[1024]; int bytesRead = unifiedSocket.getInputStream().read(buf, 0, 1024); // Make sure the settings applied above before the socket was potentially upgraded to // TLS still apply. Assert.assertEquals(tcpNoDelay, unifiedSocket.getTcpNoDelay()); Assert.assertEquals(TIMEOUT, unifiedSocket.getSoTimeout()); Assert.assertEquals(keepAlive, unifiedSocket.getKeepAlive()); if (bytesRead > 0) { byte[] dataFromClient = new byte[bytesRead]; System.arraycopy(buf, 0, dataFromClient, 0, bytesRead); synchronized (dataFromClients) { dataFromClients.add(dataFromClient); } } unifiedSocket.getOutputStream().write(dataToClient); unifiedSocket.getOutputStream().flush(); } catch (IOException e) { throw new RuntimeException(e); } finally { forceClose(unifiedSocket); } } });
@Nullable @Override public Object call() throws Exception { Socket sock = null; try { sock = new Socket(addr, 60000); X.println("Socket [timeout=" + sock.getSoTimeout() + ", linger=" + sock.getSoLinger() + ", sndBuf=" + sock.getSendBufferSize() + ", sndBuf=" + sock.getSendBufferSize() + ", NODELAY=" + sock.getTcpNoDelay() + ']'); sock.setTcpNoDelay(true); X.println("Socket [timeout=" + sock.getSoTimeout() + ", linger=" + sock.getSoLinger() + ", sndBuf=" + sock.getSendBufferSize() + ", sndBuf=" + sock.getSendBufferSize() + ", NODELAY=" + sock.getTcpNoDelay() + ']'); Thread.sleep(10000); return null; } finally { U.closeQuiet(sock); } } },