當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。