public class NioSocketChannel extends AbstractNioByteChannel implements SocketChannel
SocketChannel它使用基于NIO选择器的实现。
AbstractNioByteChannel.NioByteUnsafeAbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafeAbstractChannel.AbstractUnsafeChannel.UnsafereadInterestOp| Constructor and Description |
|---|
NioSocketChannel()
创建一个新的实例
|
NioSocketChannel(Channel parent, java.nio.channels.SocketChannel socket)
创建一个新的实例
|
NioSocketChannel(java.nio.channels.spi.SelectorProvider provider)
使用给定的
SelectorProvider创建一个新实例。
|
NioSocketChannel(java.nio.channels.SocketChannel socket)
使用给定的
SocketChannel创建一个新实例。
|
| Modifier and Type | Method and Description |
|---|---|
SocketChannelConfig |
config()
返回此频道的配置。
|
protected void |
doBind(java.net.SocketAddress localAddress)
将 Channel绑定到SocketAddress
|
protected void |
doClose()
关闭 Channel
|
protected boolean |
doConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
连接到远程对等
|
protected void |
doDisconnect()
将此 Channel从其远程对等方断开
|
protected void |
doFinishConnect()
完成连接
|
protected int |
doReadBytes(ByteBuf byteBuf)
将字节读入给定的 ByteBuf并返回金额。
|
protected void |
doShutdownOutput()
当条件证明关闭通道的输出部分时调用。
|
protected void |
doWrite(ChannelOutboundBuffer in)
将给定缓冲区的内容刷新到远程对等体。
|
protected int |
doWriteBytes(ByteBuf buf)
写字节形成给定的 ByteBuf到底层的Channel 。
|
protected long |
doWriteFileRegion(FileRegion region)
写一个 FileRegion
|
boolean |
isActive()
如果 Channel处于活动状态且已连接,则返回true 。
|
boolean |
isInputShutdown()
返回
true当且仅当远程节点关闭其输出以便从此通道接收不到更多数据时。
|
protected boolean |
isInputShutdown0() |
boolean |
isOutputShutdown() |
boolean |
isShutdown()
确定此通道的输入和输出是否都已关闭。
|
protected java.nio.channels.SocketChannel |
javaChannel() |
java.net.InetSocketAddress |
localAddress()
返回此通道绑定的本地地址。
|
protected java.net.SocketAddress |
localAddress0()
返回本地绑定的
SocketAddress 。
|
protected AbstractNioChannel.AbstractNioUnsafe |
newUnsafe()
创建一个新的 AbstractChannel.AbstractUnsafe实例,该实例将用于Channel的生命周期
|
ServerSocketChannel |
parent()
返回此频道的父级。
|
java.net.InetSocketAddress |
remoteAddress()
返回此通道连接到的远程地址。
|
protected java.net.SocketAddress |
remoteAddress0()
返回 SocketAddress其中Channel被连接到。
|
ChannelFuture |
shutdown()
将关闭此通道的输入和输出端。
|
ChannelFuture |
shutdown(ChannelPromise promise)
将关闭此通道的输入和输出端。
|
ChannelFuture |
shutdownInput()
关闭通道的输入端。
|
ChannelFuture |
shutdownInput(ChannelPromise promise)
将关闭输入并通知 ChannelPromise 。
|
ChannelFuture |
shutdownOutput() |
ChannelFuture |
shutdownOutput(ChannelPromise promise)
将关闭输出并通知 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, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, pipeline, read, toString, voidPromise, write, write, writeAndFlush, writeAndFlushattr, hasAttrclone, finalize, getClass, notify, notifyAll, wait, wait, waitalloc, 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.SocketChannel socket)
SocketChannel创建一个新实例。
public ServerSocketChannel parent()
Channel
parent在界面
Channel
parent在界面
SocketChannel
parent在课堂上
AbstractChannel
null如果此频道没有父频道。
public SocketChannelConfig config()
Channel
config在界面
Channel
config在界面
SocketChannel
protected java.nio.channels.SocketChannel javaChannel()
javaChannel在课堂上
AbstractNioChannel
public boolean isOutputShutdown()
isOutputShutdown在界面
DuplexChannel
Socket.isOutputShutdown()
public boolean isInputShutdown()
DuplexChannel
true当且仅当远程节点关闭其输出,以便从此通道接收不到更多数据时。
请注意,此方法的语义不同于Socket.shutdownInput()和Socket.isInputShutdown() 。
isInputShutdown在界面
DuplexChannel
public boolean isShutdown()
DuplexChannel复制的描述
isShutdown在界面
DuplexChannel
public java.net.InetSocketAddress localAddress()
Channel复制的描述
SocketAddress应该被下推到更具体的类型,例如InetSocketAddress以检索详细信息。
localAddress在界面
Channel
localAddress在界面
SocketChannel
localAddress在课堂上
AbstractChannel
null如果此通道未绑定。
public java.net.InetSocketAddress remoteAddress()
Channel复制的描述
SocketAddress应该被转换为更具体的类型,例如InetSocketAddress以检索详细信息。
remoteAddress在界面
Channel
remoteAddress在界面
SocketChannel
remoteAddress在课堂上
AbstractChannel
null如果此通道未连接。
如果此通道未连接,但它可以接收来自任意远程地址的消息(例如DatagramChannel ,请使用DefaultAddressedEnvelope.recipient()来确定接收消息的来源,因为此方法将返回null 。
@UnstableApi
protected final void doShutdownOutput()
throws java.lang.Exception
AbstractChannel
doShutdownOutput在课堂上
AbstractChannel
java.lang.Exception
public ChannelFuture shutdownOutput()
shutdownOutput在界面
DuplexChannel
Socket.shutdownOutput()
public ChannelFuture shutdownOutput(ChannelPromise promise)
DuplexChannel
ChannelPromise 。
shutdownOutput在界面
DuplexChannel
Socket.shutdownOutput()
public ChannelFuture shutdownInput()
AbstractNioByteChannel
shutdownInput在界面
DuplexChannel
shutdownInput在课堂上
AbstractNioByteChannel
Socket.shutdownInput()
protected boolean isInputShutdown0()
public ChannelFuture shutdownInput(ChannelPromise promise)
DuplexChannel复制的描述
ChannelPromise 。
shutdownInput ,界面
DuplexChannel
Socket.shutdownInput()
public ChannelFuture shutdown()
DuplexChannel复制的描述
shutdown在界面
DuplexChannel
public ChannelFuture shutdown(ChannelPromise promise)
DuplexChannel
shutdown在界面
DuplexChannel
promise - 将在关机操作完成时完成。
protected java.net.SocketAddress localAddress0()
AbstractChannel
SocketAddress 。
localAddress0在课堂上
AbstractChannel
protected java.net.SocketAddress remoteAddress0()
AbstractChannel
SocketAddress其中Channel被连接到。
remoteAddress0在课堂上
AbstractChannel
protected void doBind(java.net.SocketAddress localAddress)
throws java.lang.Exception
AbstractChannel
Channel绑定到SocketAddress
doBind在类
AbstractChannel
java.lang.Exception
protected boolean doConnect(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
throws java.lang.Exception
AbstractNioChannel
doConnect在课堂上
AbstractNioChannel
java.lang.Exception
protected void doFinishConnect()
throws java.lang.Exception
AbstractNioChannel
doFinishConnect在课堂
AbstractNioChannel
java.lang.Exception
protected void doDisconnect()
throws java.lang.Exception
AbstractChannel
Channel从其远程对等方断开
doDisconnect在课堂上
AbstractChannel
java.lang.Exception
protected void doClose()
throws java.lang.Exception
AbstractChannel
Channel
doClose在课堂
AbstractNioChannel
java.lang.Exception
protected int doReadBytes(ByteBuf byteBuf) throws java.lang.Exception
AbstractNioByteChannel
ByteBuf并返回金额。
doReadBytes在课堂上
AbstractNioByteChannel
java.lang.Exception
protected int doWriteBytes(ByteBuf buf) throws java.lang.Exception
AbstractNioByteChannel
ByteBuf写入底层的Channel 。
doWriteBytes在课堂上
AbstractNioByteChannel
buf - 应写入字节的ByteBuf
java.lang.Exception
protected long doWriteFileRegion(FileRegion region) throws java.lang.Exception
AbstractNioByteChannel
FileRegion
doWriteFileRegion在课堂上
AbstractNioByteChannel
region - 应写入字节的FileRegion
java.lang.Exception
protected void doWrite(ChannelOutboundBuffer in) throws java.lang.Exception
AbstractChannel
doWrite在课堂上
AbstractNioByteChannel
java.lang.Exception
protected AbstractNioChannel.AbstractNioUnsafe newUnsafe()
AbstractChannel
AbstractChannel.AbstractUnsafe实例,该实例将用于Channel的生命周期
newUnsafe在课堂上
AbstractNioByteChannel
Copyright © 2008–2018 The Netty Project. All rights reserved.