public class AioSession extends Object implements Closeable
| Constructor and Description |
|---|
AioSession(AsynchronousSocketChannel channel,
IoAction<ByteBuffer> ioAction,
SocketConfig config)
构造
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
callbackRead()
执行读,用于读取事件结束的回调
|
void |
close()
关闭会话
|
AioSession |
closeIn()
关闭输出
|
AioSession |
closeOut()
关闭输出
|
AsynchronousSocketChannel |
getChannel()
|
IoAction<ByteBuffer> |
getIoAction()
获取消息处理器
|
ByteBuffer |
getReadBuffer()
获取读取Buffer
|
SocketAddress |
getRemoteAddress()
获取远程主机(客户端)地址和端口
|
ByteBuffer |
getWriteBuffer()
获取写Buffer
|
boolean |
isOpen()
会话是否打开状态
当Socket保持连接时会话始终打开 |
AioSession |
read()
读取数据到Buffer
|
AioSession |
read(CompletionHandler<Integer,AioSession> handler)
读取数据到Buffer
|
Future<Integer> |
write(ByteBuffer data)
写数据到目标端
|
AioSession |
write(ByteBuffer data,
CompletionHandler<Integer,AioSession> handler)
写数据到目标端
|
AioSession |
writeAndClose(ByteBuffer data)
写数据到目标端,并关闭输出
|
public AioSession(AsynchronousSocketChannel channel, IoAction<ByteBuffer> ioAction, SocketConfig config)
channel - AsynchronousSocketChannelioAction - IO消息处理类config - 配置项public AsynchronousSocketChannel getChannel()
AsynchronousSocketChannelpublic ByteBuffer getReadBuffer()
public ByteBuffer getWriteBuffer()
public IoAction<ByteBuffer> getIoAction()
IoActionpublic SocketAddress getRemoteAddress()
public AioSession read()
public AioSession read(CompletionHandler<Integer,AioSession> handler)
handler - CompletionHandlerpublic AioSession writeAndClose(ByteBuffer data)
data - 数据public Future<Integer> write(ByteBuffer data)
data - 数据Futurepublic AioSession write(ByteBuffer data, CompletionHandler<Integer,AioSession> handler)
data - 数据handler - CompletionHandlerpublic boolean isOpen()
public AioSession closeIn()
public AioSession closeOut()
public void close()
close in interface Closeableclose in interface AutoCloseableprotected void callbackRead()
Copyright © 2025. All rights reserved.