Package org.aoju.bus.socket.channel
Class AsynchronousSocketChannel
java.lang.Object
java.nio.channels.AsynchronousSocketChannel
org.aoju.bus.socket.channel.AsynchronousSocketChannel
- All Implemented Interfaces:
Closeable,AutoCloseable,AsynchronousByteChannel,AsynchronousChannel,Channel,NetworkChannel
模拟JDK7的AIO处理方式
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionAsynchronousSocketChannel(AsynchronousChannelGroup group, SocketChannel channel) -
Method Summary
Modifier and TypeMethodDescriptionbind(SocketAddress local) voidclose()connect(SocketAddress remote) <A> voidconnect(SocketAddress remote, A attachment, CompletionHandler<Void, ? super A> handler) voidvoiddoRead(boolean direct) voiddoWrite()<T> TgetOption(SocketOption<T> name) booleanisOpen()read(ByteBuffer readBuffer) <A> voidread(ByteBuffer[] dsts, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) <A> voidread(ByteBuffer dst, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler) setOption(SocketOption<T> name, T value) Set<SocketOption<?>>write(ByteBuffer src) <A> voidwrite(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) <A> voidwrite(ByteBuffer src, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler)
-
Constructor Details
-
AsynchronousSocketChannel
public AsynchronousSocketChannel(AsynchronousChannelGroup group, SocketChannel channel) throws IOException - Throws:
IOException
-
-
Method Details
-
close
- Throws:
IOException
-
bind
- Specified by:
bindin interfaceNetworkChannel- Specified by:
bindin classAsynchronousSocketChannel- Throws:
IOException
-
setOption
- Specified by:
setOptionin interfaceNetworkChannel- Specified by:
setOptionin classAsynchronousSocketChannel- Throws:
IOException
-
getOption
- Throws:
IOException
-
supportedOptions
-
shutdownInput
- Specified by:
shutdownInputin classAsynchronousSocketChannel- Throws:
IOException
-
shutdownOutput
- Specified by:
shutdownOutputin classAsynchronousSocketChannel- Throws:
IOException
-
getRemoteAddress
- Specified by:
getRemoteAddressin classAsynchronousSocketChannel- Throws:
IOException
-
connect
public <A> void connect(SocketAddress remote, A attachment, CompletionHandler<Void, ? super A> handler) - Specified by:
connectin classAsynchronousSocketChannel
-
connect
- Specified by:
connectin classAsynchronousSocketChannel
-
read
public <A> void read(ByteBuffer dst, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler) - Specified by:
readin classAsynchronousSocketChannel
-
read
- Specified by:
readin interfaceAsynchronousByteChannel- Specified by:
readin classAsynchronousSocketChannel
-
read
public <A> void read(ByteBuffer[] dsts, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) - Specified by:
readin classAsynchronousSocketChannel
-
write
public <A> void write(ByteBuffer src, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler) - Specified by:
writein classAsynchronousSocketChannel
-
write
- Specified by:
writein interfaceAsynchronousByteChannel- Specified by:
writein classAsynchronousSocketChannel
-
write
public <A> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) - Specified by:
writein classAsynchronousSocketChannel
-
getLocalAddress
- Specified by:
getLocalAddressin interfaceNetworkChannel- Specified by:
getLocalAddressin classAsynchronousSocketChannel- Throws:
IOException
-
doConnect
public void doConnect() -
doRead
public void doRead(boolean direct) -
doWrite
public void doWrite() -
isOpen
public boolean isOpen()
-