当前位置: 首页>>代码示例>>Java>>正文


Java AsynchronousSocketChannel.getRemoteAddress方法代码示例

本文整理汇总了Java中java.nio.channels.AsynchronousSocketChannel.getRemoteAddress方法的典型用法代码示例。如果您正苦于以下问题:Java AsynchronousSocketChannel.getRemoteAddress方法的具体用法?Java AsynchronousSocketChannel.getRemoteAddress怎么用?Java AsynchronousSocketChannel.getRemoteAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.channels.AsynchronousSocketChannel的用法示例。


在下文中一共展示了AsynchronousSocketChannel.getRemoteAddress方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SocketSession

import java.nio.channels.AsynchronousSocketChannel; //导入方法依赖的package包/类
public SocketSession(AsynchronousSocketChannel channel, ByteBuffer buffer,
		CodecFactory codecFactory) throws IOException {
	this.channel = channel;
	this.remoteAddress = channel.getRemoteAddress();
	this.processor = new Processor(this);
	this.buffer = buffer;
	this.codec = codecFactory.getCodec();
	this.describe = "local:" + channel.getLocalAddress() + " remote:"
			+ remoteAddress + " hashCode/" + super.hashCode();
	this.hashCode = super.hashCode();
	attachment = new ConcurrentHashMap<Object, Object>(128);
	this.attachment.put(MSG_SURPLUS_LENGTH, -1);
	this.attachment.put(MSG_TMP, new byte[0]);
	this.remotePort = Integer.parseInt(this.toString().split(" ")[1]
			.split(":")[2]);
}
 
开发者ID:finikes,项目名称:tridge,代码行数:17,代码来源:SocketSession.java

示例2: failed

import java.nio.channels.AsynchronousSocketChannel; //导入方法依赖的package包/类
@Override
public void failed(Throwable ex, ConnectParam param)
{
	AsynchronousSocketChannel channel = param.channel;
	try
	{
		SocketAddress addr = (channel.isOpen() ? channel.getRemoteAddress() : null);
		closeChannel(channel);
		onConnectFailed(addr, ex);
	}
	catch(Exception e)
	{
		closeChannel(channel);
		doException(null, e);
	}
}
 
开发者ID:dwing4g,项目名称:jane,代码行数:17,代码来源:TcpManager.java

示例3: getClientIdBySocketChannel

import java.nio.channels.AsynchronousSocketChannel; //导入方法依赖的package包/类
public static long getClientIdBySocketChannel(AsynchronousSocketChannel socketChannel) throws IOException{
  	InetSocketAddress address = (InetSocketAddress)socketChannel.getRemoteAddress();
  	byte[] quad = address.getAddress().getAddress();
int port = address.getPort();
long clientId = NetworkUtil.convertIpPortToUniqueId(quad, port);
return clientId;
  }
 
开发者ID:zijan,项目名称:Tatala-RPC,代码行数:8,代码来源:NetworkUtil.java

示例4: FrontendConnection

import java.nio.channels.AsynchronousSocketChannel; //导入方法依赖的package包/类
public FrontendConnection(AsynchronousSocketChannel channel)
		throws IOException {
	super(channel);
	InetSocketAddress localAddr = (InetSocketAddress) channel
			.getLocalAddress();
	InetSocketAddress remoteAddr = (InetSocketAddress) channel
			.getRemoteAddress();
	this.host = remoteAddr.getHostString();
	this.port = localAddr.getPort();
	this.localPort = remoteAddr.getPort();
	this.handler = new FrontendAuthenticator(this);
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:13,代码来源:FrontendConnection.java

示例5: FrontendConnection

import java.nio.channels.AsynchronousSocketChannel; //导入方法依赖的package包/类
public FrontendConnection(AsynchronousSocketChannel channel)
		throws IOException {
	super(channel);
	InetSocketAddress localAddr = (InetSocketAddress) channel
			.getLocalAddress();
	InetSocketAddress remoteAddr = (InetSocketAddress) channel
			.getRemoteAddress();
	this.host = localAddr.getHostString();
	this.port = localAddr.getPort();
	this.localPort = remoteAddr.getPort();
	this.handler = new FrontendAuthenticator(this);
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:13,代码来源:FrontendConnection.java

示例6: Node

import java.nio.channels.AsynchronousSocketChannel; //导入方法依赖的package包/类
Node(SocketProvider provider, PoolManager pool_manager, AsynchronousSocketChannel channel) {
	this.provider = provider;
	if (provider == null) {
		throw new NullPointerException("\"provider\" can't to be null");
	}
	this.pool_manager = pool_manager;
	if (pool_manager == null) {
		throw new NullPointerException("\"pool_manager\" can't to be null");
	}
	this.channel = channel;
	if (channel == null) {
		throw new NullPointerException("\"channel\" can't to be null");
	}
	
	this.read_buffer = ByteBuffer.allocateDirect(Protocol.BUFFER_SIZE);
	this.write_buffer = ByteBuffer.allocateDirect(Protocol.BUFFER_SIZE);
	
	this.pressure_measurement_recevied = pool_manager.getPressureMeasurementRecevied();
	if (pressure_measurement_recevied == null) {
		throw new NullPointerException("\"pressure_measurement_recevied\" can't to be null");
	}
	this.pressure_measurement_sended = pool_manager.getPressureMeasurementSended();
	if (pressure_measurement_sended == null) {
		throw new NullPointerException("\"pressure_measurement_sended\" can't to be null");
	}
	last_activity = new AtomicLong(System.currentTimeMillis());
	
	try {
		socket_addr = (InetSocketAddress) channel.getRemoteAddress();
	} catch (IOException e) {
	}
	server_delta_time = 0;
	create_date = System.currentTimeMillis();
	provider_type = provider.getTypeName();
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:36,代码来源:Node.java

示例7: createClientNode

import java.nio.channels.AsynchronousSocketChannel; //导入方法依赖的package包/类
/** 
 * @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.getRemoteAddress();
	Node clientNode = new Node(inetSocketAddress.getHostString(), inetSocketAddress.getPort());
	return clientNode;
}
 
开发者ID:tywo45,项目名称:talent-aio,代码行数:18,代码来源:ServerChannelContext.java


注:本文中的java.nio.channels.AsynchronousSocketChannel.getRemoteAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。