本文整理汇总了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;
}