public class NioSocketChannel extends AbstractNioByteChannel implements SocketChannel
SocketChannel which uses NIO selector based implementation.AbstractNioByteChannel.NioByteUnsafeAbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafeAbstractChannel.AbstractUnsafeChannel.UnsafereadInterestOp| Constructor and Description |
|---|
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.SocketChannel socket)
Create a new instance using the given
SocketChannel. |
| Modifier and Type | Method and Description |
|---|---|
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()
Return
true if the input of this Channel is shutdown |
boolean |
isOutputShutdown() |
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. |
ChannelMetadata |
metadata()
|
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 |
shutdownOutput() |
ChannelFuture |
shutdownOutput(ChannelPromise promise) |
clearOpWrite, filterOutboundMessage, incompleteWrite, setOpWritedoBeginRead, doDeregister, doRegister, eventLoop, isCompatible, isOpen, isReadPending, newDirectBuffer, newDirectBuffer, selectionKey, setReadPending, unsafealloc, bind, bind, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, equals, flush, hashCode, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, newChannelPipeline, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, pipeline, read, toString, voidPromise, write, write, writeAndFlush, writeAndFlushattrclone, finalize, getClass, notify, notifyAll, wait, wait, waitalloc, bind, bind, close, close, closeFuture, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, eventLoop, flush, isOpen, isRegistered, isWritable, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, pipeline, read, unsafe, voidPromise, write, write, writeAndFlush, writeAndFlushattrpublic NioSocketChannel()
public NioSocketChannel(java.nio.channels.spi.SelectorProvider provider)
SelectorProvider.public NioSocketChannel(java.nio.channels.SocketChannel socket)
SocketChannel.public ServerSocketChannel parent()
Channelparent in interface Channelparent in interface SocketChannelparent in class AbstractChannelnull if this channel does not have a parent channel.public ChannelMetadata metadata()
Channelpublic SocketChannelConfig config()
Channelconfig in interface Channelconfig in interface SocketChannelprotected java.nio.channels.SocketChannel javaChannel()
javaChannel in class AbstractNioChannelpublic boolean isActive()
Channeltrue if the Channel is active and so connected.public boolean isInputShutdown()
AbstractNioChanneltrue if the input of this Channel is shutdownisInputShutdown in interface DuplexChannelisInputShutdown in class AbstractNioChannelpublic java.net.InetSocketAddress localAddress()
ChannelSocketAddress is supposed to be down-cast into more concrete
type such as InetSocketAddress to retrieve the detailed
information.localAddress in interface ChannellocalAddress in interface SocketChannellocalAddress in class 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 in interface ChannelremoteAddress in interface SocketChannelremoteAddress in class 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 in class AbstractChanneljava.lang.Exceptionpublic boolean isOutputShutdown()
isOutputShutdown in interface DuplexChannelSocket.isOutputShutdown()public ChannelFuture shutdownOutput()
shutdownOutput in interface DuplexChannelSocket.shutdownOutput()public ChannelFuture shutdownOutput(ChannelPromise promise)
shutdownOutput in interface DuplexChannelWill notify the given {@link ChannelPromise}protected java.net.SocketAddress localAddress0()
AbstractChannelSocketAddress which is bound locally.localAddress0 in class AbstractChannelprotected java.net.SocketAddress remoteAddress0()
AbstractChannelSocketAddress which the Channel is connected to.remoteAddress0 in class AbstractChannelprotected void doBind(java.net.SocketAddress localAddress)
throws java.lang.Exception
AbstractChannelChannel to the SocketAddressdoBind in class AbstractChanneljava.lang.Exceptionprotected boolean doConnect(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
throws java.lang.Exception
AbstractNioChanneldoConnect in class AbstractNioChanneljava.lang.Exceptionprotected void doFinishConnect()
throws java.lang.Exception
AbstractNioChanneldoFinishConnect in class AbstractNioChanneljava.lang.Exceptionprotected void doDisconnect()
throws java.lang.Exception
AbstractChannelChannel from its remote peerdoDisconnect in class AbstractChanneljava.lang.Exceptionprotected void doClose()
throws java.lang.Exception
AbstractChannelChanneldoClose in class AbstractNioChanneljava.lang.Exceptionprotected int doReadBytes(ByteBuf byteBuf) throws java.lang.Exception
AbstractNioByteChannelByteBuf and return the amount.doReadBytes in class AbstractNioByteChanneljava.lang.Exceptionprotected int doWriteBytes(ByteBuf buf) throws java.lang.Exception
AbstractNioByteChannelByteBuf to the underlying Channel.doWriteBytes in class AbstractNioByteChannelbuf - the ByteBuf from which the bytes should be writtenjava.lang.Exceptionprotected long doWriteFileRegion(FileRegion region) throws java.lang.Exception
AbstractNioByteChannelFileRegiondoWriteFileRegion in class AbstractNioByteChannelregion - the FileRegion from which the bytes should be writtenjava.lang.Exceptionprotected void doWrite(ChannelOutboundBuffer in) throws java.lang.Exception
AbstractChanneldoWrite in class AbstractNioByteChanneljava.lang.Exceptionprotected AbstractNioChannel.AbstractNioUnsafe newUnsafe()
AbstractChannelAbstractChannel.AbstractUnsafe instance which will be used for the life-time of the ChannelnewUnsafe in class AbstractNioByteChannelCopyright © 2008–2018 The Netty Project. All rights reserved.