本文整理匯總了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]);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}