public class AioSocket extends SocketContext
bufferSize, connectModel, filterChain, handler, host, idleInterval, messageSplitter, port, readTimeout, sslManager| 限定符 | 构造器和说明 |
|---|---|
protected |
AioSocket(SocketContext parentSocketContext,
AsynchronousSocketChannel socketChannel)
构造函数
|
|
AioSocket(String host,
int port,
int readTimeout)
构造函数
|
|
AioSocket(String host,
int port,
int readTimeout,
int idleInterval)
构造函数
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
acceptStart()
用于针对 Accept 进来的 Socket 连接的启动
|
protected void |
catchConnected()
捕获 Aio Connect
|
protected void |
catchRead(ByteBuffer buffer)
捕获 Aio Read
|
boolean |
close()
关闭连接
|
AioSession |
getSession()
获取 Session 对象
|
boolean |
isConnected()
上下文连接是否连接
|
boolean |
isOpen()
上下文连接是否打开
|
AioSocket |
restart()
重连当前连接
|
void |
setIdleInterval(int idleInterval)
设置空闲事件时间
|
<T> void |
setOption(SocketOption<T> name,
T value)
设置 Socket 的 Option 选项
|
AsynchronousSocketChannel |
socketChannel()
获取 SocketChannel 对象
|
void |
start()
启动上下文连接
阻塞方法
|
Object |
synchronouRead()
同步读取消息
|
void |
synchronouSend(Object obj)
同步发送消息
|
void |
syncStart()
启动同步的上下文连接
非阻塞方法
|
copyFrom, filterChain, getBufferSize, getConnectModel, getHost, getIdleInterval, getPort, getReadTimeout, getSSLManager, handler, handler, initSSL, messageSplitter, messageSplitter, setBufferSize, setSSLManager, waitConnectedpublic AioSocket(String host, int port, int readTimeout) throws IOException
host - 主机地址port - 主机端口readTimeout - 主机超时时间 (milliseconds)IOException - IO 异常public AioSocket(String host, int port, int readTimeout, int idleInterval) throws IOException
host - 主机地址port - 主机端口idleInterval - 空闲事件触发时间, 单位: 秒readTimeout - 主机超时时间 (milliseconds)IOException - IO 异常protected AioSocket(SocketContext parentSocketContext, AsynchronousSocketChannel socketChannel) throws IOException
parentSocketContext - 父异步 socket 通道socketChannel - 异步 socket 通道IOException - IO 异常public void setIdleInterval(int idleInterval)
SocketContextsetIdleInterval 在类中 SocketContextidleInterval - 空闲事件时间, 单位:秒public <T> void setOption(SocketOption<T> name, T value) throws IOException
setOption 在类中 SocketContextT - 范型name - SocketOption类型的枚举, 参照:AsynchronousSocketChannel.setOption的说明value - SocketOption参数IOException - IO异常protected void catchConnected()
throws IOException
IOException - IO 异常protected void catchRead(ByteBuffer buffer)
buffer - 缓冲区public AioSession getSession()
public void start()
throws IOException
start 在类中 SocketContextIOException - IO 异常public void syncStart()
throws IOException
syncStart 在类中 SocketContextIOException - IO异常protected void acceptStart()
throws IOException
SocketContextacceptStart 在类中 SocketContextIOException - IO异常public AioSocket restart() throws IOException, RestartException
IOException - IO 异常RestartException - 重新启动的异常public AsynchronousSocketChannel socketChannel()
public boolean isOpen()
SocketContextisOpen 在类中 SocketContextpublic boolean isConnected()
SocketContextisConnected 在类中 SocketContextpublic Object synchronouRead() throws ReadMessageException
ReadMessageException - 读取消息异常public void synchronouSend(Object obj) throws SendMessageException
obj - 要发送的对象SendMessageException - 消息发送异常public boolean close()
SocketContextclose 在类中 SocketContextCopyright © 2017 Voovan. All rights reserved.