Java Code Examples for java.nio.channels.AsynchronousSocketChannel#getLocalAddress()

The following examples show how to use java.nio.channels.AsynchronousSocketChannel#getLocalAddress() . 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: ChannelContext.java    From oxygen with Apache License 2.0 5 votes vote down vote up
public void setChannel(AsynchronousSocketChannel channel) {
  this.channel = channel;
  try {
    if (isServer()) {
      this.address = (InetSocketAddress) channel.getRemoteAddress();
    } else {
      this.address = (InetSocketAddress) channel.getLocalAddress();
    }
  } catch (IOException ignore) {
    //ignore
  }
  this.future = new CompletableFuture<>();
}
 
Example 2
Source File: ClientChannelContext.java    From t-io with Apache License 2.0 3 votes vote down vote up
/**
 * @see org.tio.core.ChannelContext#createClientNode(java.nio.channels.AsynchronousSocketChannel)
 *
 * @param asynchronousSocketChannel
 * @return
 * @throws IOException
 * @author tanyaowu
 * 2016年12月6日 下午12:18:08
 *
 */
@Override
public Node createClientNode(AsynchronousSocketChannel asynchronousSocketChannel) throws IOException {
	InetSocketAddress inetSocketAddress = (InetSocketAddress) asynchronousSocketChannel.getLocalAddress();
	Node clientNode = new Node(inetSocketAddress.getHostString(), inetSocketAddress.getPort());
	return clientNode;
}
 
Example 3
Source File: ClientChannelContext.java    From talent-aio with GNU Lesser General Public License v2.1 3 votes vote down vote up
/** 
 * @see com.talent.aio.common.ChannelContext#createClientNode(java.nio.channels.AsynchronousSocketChannel)
 * 
 * @param asynchronousSocketChannel
 * @return
 * @throws IOException 
 * @重写人: tanyaowu
 * @重写时间: 2016年12月6日 下午12:18:08
 * 
 */
@Override
public Node createClientNode(AsynchronousSocketChannel asynchronousSocketChannel) throws IOException
{
	InetSocketAddress inetSocketAddress = (InetSocketAddress) asynchronousSocketChannel.getLocalAddress();
	Node clientNode = new Node(inetSocketAddress.getHostString(), inetSocketAddress.getPort());
	return clientNode;
}