public class NioSocketChannel extends AbstractNioByteChannel implements SocketChannel
SocketChannel which uses NIO selector based implementation.AbstractNioByteChannel.NioByteUnsafeAbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafeAbstractChannel.AbstractUnsafeChannel.UnsafereadInterestOp| 构造器和说明 |
|---|
NioSocketChannel()
Create a new instance
|
NioSocketChannel(Channel parent,
java.nio.channels.SocketChannel socket)
Create a new instance
|
NioSocketChannel(java.nio.channels.spi.SelectorProvider provider)
Create a new instance using the given
SelectorProvider. |
NioSocketChannel(java.nio.channels.spi.SelectorProvider provider,
InternetProtocolFamily family)
Create a new instance using the given
SelectorProvider and protocol family (supported only since JDK 15). |
NioSocketChannel(java.nio.channels.SocketChannel socket)
Create a new instance using the given
SocketChannel. |
| 限定符和类型 | 方法和说明 |
|---|---|
SocketChannelConfig |
config()
Returns the configuration of this channel.
|
protected void |
doBind(java.net.SocketAddress localAddress)
Bind the
Channel to the SocketAddress |
protected void |
doClose()
Close the
Channel |
protected boolean |
doConnect(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
Connect to the remote peer
|
protected void |
doDisconnect()
Disconnect this
Channel from its remote peer |
protected void |
doFinishConnect()
Finish the connect
|
protected int |
doReadBytes(ByteBuf byteBuf)
Read bytes into the given
ByteBuf and return the amount. |
protected void |
doShutdownOutput()
Called when conditions justify shutting down the output portion of the channel.
|
protected void |
doWrite(ChannelOutboundBuffer in)
Flush the content of the given buffer to the remote peer.
|
protected int |
doWriteBytes(ByteBuf buf)
Write bytes form the given
ByteBuf to the underlying Channel. |
protected long |
doWriteFileRegion(FileRegion region)
Write a
FileRegion |
boolean |
isActive()
Return
true if the Channel is active and so connected. |
boolean |
isInputShutdown()
Returns
true if and only if the remote peer shut down its output so that no more
data is received from this channel. |
protected boolean |
isInputShutdown0() |
boolean |
isOutputShutdown() |
boolean |
isShutdown()
Determine if both the input and output of this channel have been shutdown.
|
protected java.nio.channels.SocketChannel |
javaChannel() |
java.net.InetSocketAddress |
localAddress()
Returns the local address where this channel is bound to.
|
protected java.net.SocketAddress |
localAddress0()
Returns the
SocketAddress which is bound locally. |
protected AbstractNioChannel.AbstractNioUnsafe |
newUnsafe()
Create a new
AbstractChannel.AbstractUnsafe instance which will be used for the life-time of the Channel |
ServerSocketChannel |
parent()
Returns the parent of this channel.
|
java.net.InetSocketAddress |
remoteAddress()
Returns the remote address where this channel is connected to.
|
protected java.net.SocketAddress |
remoteAddress0()
Return the
SocketAddress which the Channel is connected to. |
ChannelFuture |
shutdown()
Will shutdown the input and output sides of this channel.
|
ChannelFuture |
shutdown(ChannelPromise promise)
Will shutdown the input and output sides of this channel.
|
ChannelFuture |
shutdownInput()
Shutdown the input side of the channel.
|
ChannelFuture |
shutdownInput(ChannelPromise promise)
Will shutdown the input and notify
ChannelPromise. |
ChannelFuture |
shutdownOutput() |
ChannelFuture |
shutdownOutput(ChannelPromise promise)
Will shutdown the output and notify
ChannelPromise. |
clearOpWrite, doWrite0, filterOutboundMessage, incompleteWrite, metadata, setOpWriteclearReadPending, doBeginRead, doDeregister, doRegister, eventLoop, isCompatible, isOpen, isReadPending, newDirectBuffer, newDirectBuffer, selectionKey, setReadPending, unsafealloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, equals, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, maxMessagesPerWrite, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, pipeline, read, toString, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlushattr, hasAttralloc, bytesBeforeUnwritable, bytesBeforeWritable, closeFuture, eventLoop, flush, id, isOpen, isRegistered, isWritable, metadata, pipeline, read, unsafeattr, hasAttrbind, bind, close, close, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, voidPromise, write, write, writeAndFlush, writeAndFlushpublic NioSocketChannel()
public NioSocketChannel(java.nio.channels.spi.SelectorProvider provider)
SelectorProvider.public NioSocketChannel(java.nio.channels.spi.SelectorProvider provider,
InternetProtocolFamily family)
SelectorProvider and protocol family (supported only since JDK 15).public NioSocketChannel(java.nio.channels.SocketChannel socket)
SocketChannel.public ServerSocketChannel parent()
Channelparent 在接口中 Channelparent 在接口中 SocketChannelparent 在类中 AbstractChannelnull if this channel does not have a parent channel.public SocketChannelConfig config()
Channelconfig 在接口中 Channelconfig 在接口中 SocketChannelprotected java.nio.channels.SocketChannel javaChannel()
javaChannel 在类中 AbstractNioChannelpublic boolean isActive()
Channeltrue if the Channel is active and so connected.public boolean isOutputShutdown()
isOutputShutdown 在接口中 DuplexChannelSocket.isOutputShutdown()public boolean isInputShutdown()
DuplexChanneltrue if and only if the remote peer shut down its output so that no more
data is received from this channel. Note that the semantic of this method is different from
that of Socket.shutdownInput() and Socket.isInputShutdown().isInputShutdown 在接口中 DuplexChannelpublic boolean isShutdown()
DuplexChannelisShutdown 在接口中 DuplexChannelpublic java.net.InetSocketAddress localAddress()
ChannelSocketAddress is supposed to be down-cast into more concrete
type such as InetSocketAddress to retrieve the detailed
information.localAddress 在接口中 ChannellocalAddress 在接口中 SocketChannellocalAddress 在类中 AbstractChannelnull if this channel is not bound.public java.net.InetSocketAddress remoteAddress()
ChannelSocketAddress is supposed to be down-cast into more
concrete type such as InetSocketAddress to retrieve the detailed
information.remoteAddress 在接口中 ChannelremoteAddress 在接口中 SocketChannelremoteAddress 在类中 AbstractChannelnull if this channel is not connected.
If this channel is not connected but it can receive messages
from arbitrary remote addresses (e.g. DatagramChannel,
use DefaultAddressedEnvelope.recipient() to determine
the origination of the received message as this method will
return null.@UnstableApi protected final void doShutdownOutput() throws java.lang.Exception
AbstractChanneldoShutdownOutput 在类中 AbstractChanneljava.lang.Exceptionpublic ChannelFuture shutdownOutput()
shutdownOutput 在接口中 DuplexChannelSocket.shutdownOutput()public ChannelFuture shutdownOutput(ChannelPromise promise)
DuplexChannelChannelPromise.shutdownOutput 在接口中 DuplexChannelSocket.shutdownOutput()public ChannelFuture shutdownInput()
AbstractNioByteChannelshutdownInput 在接口中 DuplexChannelshutdownInput 在类中 AbstractNioByteChannelSocket.shutdownInput()protected boolean isInputShutdown0()
public ChannelFuture shutdownInput(ChannelPromise promise)
DuplexChannelChannelPromise.shutdownInput 在接口中 DuplexChannelSocket.shutdownInput()public ChannelFuture shutdown()
DuplexChannelshutdown 在接口中 DuplexChannelpublic ChannelFuture shutdown(ChannelPromise promise)
DuplexChannelshutdown 在接口中 DuplexChannelpromise - will be completed when both shutdown operations complete.protected java.net.SocketAddress localAddress0()
AbstractChannelSocketAddress which is bound locally.localAddress0 在类中 AbstractChannelprotected java.net.SocketAddress remoteAddress0()
AbstractChannelSocketAddress which the Channel is connected to.remoteAddress0 在类中 AbstractChannelprotected void doBind(java.net.SocketAddress localAddress)
throws java.lang.Exception
AbstractChannelChannel to the SocketAddressdoBind 在类中 AbstractChanneljava.lang.Exceptionprotected boolean doConnect(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
throws java.lang.Exception
AbstractNioChanneldoConnect 在类中 AbstractNioChanneljava.lang.Exceptionprotected void doFinishConnect()
throws java.lang.Exception
AbstractNioChanneldoFinishConnect 在类中 AbstractNioChanneljava.lang.Exceptionprotected void doDisconnect()
throws java.lang.Exception
AbstractChannelChannel from its remote peerdoDisconnect 在类中 AbstractChanneljava.lang.Exceptionprotected void doClose()
throws java.lang.Exception
AbstractChannelChanneldoClose 在类中 AbstractNioChanneljava.lang.Exceptionprotected int doReadBytes(ByteBuf byteBuf) throws java.lang.Exception
AbstractNioByteChannelByteBuf and return the amount.doReadBytes 在类中 AbstractNioByteChanneljava.lang.Exceptionprotected int doWriteBytes(ByteBuf buf) throws java.lang.Exception
AbstractNioByteChannelByteBuf to the underlying Channel.doWriteBytes 在类中 AbstractNioByteChannelbuf - the ByteBuf from which the bytes should be writtenjava.lang.Exceptionprotected long doWriteFileRegion(FileRegion region) throws java.lang.Exception
AbstractNioByteChannelFileRegiondoWriteFileRegion 在类中 AbstractNioByteChannelregion - the FileRegion from which the bytes should be writtenjava.lang.Exceptionprotected void doWrite(ChannelOutboundBuffer in) throws java.lang.Exception
AbstractChanneldoWrite 在类中 AbstractNioByteChanneljava.lang.Exceptionprotected AbstractNioChannel.AbstractNioUnsafe newUnsafe()
AbstractChannelAbstractChannel.AbstractUnsafe instance which will be used for the life-time of the ChannelnewUnsafe 在类中 AbstractNioByteChannel