List of usage examples for java.net StandardSocketOptions TCP_NODELAY
SocketOption TCP_NODELAY
To view the source code for java.net StandardSocketOptions TCP_NODELAY.
Click Source Link
From source file:ee.ria.xroad.proxy.clientproxy.FastestSocketSelector.java
private SocketInfo initConnections(Selector selector) throws IOException { log.trace("initConnections()"); for (URI target : addresses) { SocketChannel channel = SocketChannel.open(); channel.setOption(StandardSocketOptions.TCP_NODELAY, true); channel.configureBlocking(false); try {//from w w w . j av a2 s . c om channel.register(selector, SelectionKey.OP_CONNECT, target); if (channel.connect(new InetSocketAddress(target.getHost(), target.getPort()))) { // connected immediately channel.configureBlocking(true); return new SocketInfo(target, channel.socket()); } } catch (Exception e) { closeQuietly(channel); log.trace("Error connecting to '{}': {}", target, e); } } return null; }