org.jboss.netty.channel.socket.nio.NioSocketChannelConfig Java Examples
The following examples show how to use
org.jboss.netty.channel.socket.nio.NioSocketChannelConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Connection.java From nfs-client-java with Apache License 2.0 | 4 votes |
/** * If there is no current connection, start a new tcp connection asynchronously. * * @throws RpcException */ protected void connect() throws RpcException { if (_state.equals(State.CONNECTED)) { return; } final ChannelFuture oldChannelFuture = _channelFuture; if (LOG.isDebugEnabled()) { String logPrefix = _usePrivilegedPort ? "usePrivilegedPort " : ""; LOG.debug("{}connecting to {}", logPrefix, getRemoteAddress()); } _state = State.CONNECTING; if (_usePrivilegedPort) { _channel = bindToPrivilegedPort(); _channelFuture = _channel.connect(getRemoteAddress()); } else { _channelFuture = _clientBootstrap.connect(); _channel = _channelFuture.getChannel(); } NioSocketChannelConfig cfg = (NioSocketChannelConfig) _channel.getConfig(); cfg.setWriteBufferHighWaterMark(MAX_SENDING_QUEUE_SIZE); _channelFuture.addListener(new ChannelFutureListener() { /* (non-Javadoc) * @see org.jboss.netty.channel.ChannelFutureListener#operationComplete(org.jboss.netty.channel.ChannelFuture) */ public void operationComplete(ChannelFuture future) { if (_channelFuture.isSuccess()) { _state = State.CONNECTED; oldChannelFuture.setSuccess(); } else { _state = State.DISCONNECTED; oldChannelFuture.cancel(); } } }); }