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,
SocketChannel socket)
Create a new instance
|
NioSocketChannel(SelectorProvider provider)
Create a new instance using the given
SelectorProvider. |
NioSocketChannel(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(SocketAddress localAddress)
Bind the
Channel to the SocketAddress |
protected void |
doClose()
Close the
Channel |
protected boolean |
doConnect(SocketAddress remoteAddress,
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 |
doWrite(ChannelOutboundBuffer in)
Flush the content of the given buffer to the remote peer.
|
protected int |
doWriteBytes(ByteBuf buf)
|
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 SocketChannel |
javaChannel() |
InetSocketAddress |
localAddress()
Returns the local address where this channel is bound to.
|
protected 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.
|
InetSocketAddress |
remoteAddress()
Returns the remote address where this channel is connected to.
|
protected SocketAddress |
remoteAddress0()
Return the
SocketAddress which the Channel is connected to. |
ChannelFuture |
shutdownOutput() |
ChannelFuture |
shutdownOutput(ChannelPromise promise) |
clearOpWrite, filterOutboundMessage, incompleteWrite, setOpWritedoBeginRead, doDeregister, doRegister, isCompatible, isOpen, isReadPending, newDirectBuffer, newDirectBuffer, selectionKey, setReadPending, unsafealloc, bind, bind, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, equals, eventLoop, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, pipeline, read, toString, voidPromise, write, write, writeAndFlush, writeAndFlushattr, hasAttrclone, finalize, getClass, notify, notifyAll, wait, wait, waitalloc, bind, bind, close, close, closeFuture, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, eventLoop, flush, id, isOpen, isRegistered, isWritable, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, pipeline, read, unsafe, voidPromise, write, write, writeAndFlush, writeAndFlushattr, hasAttrcompareTopublic NioSocketChannel()
public NioSocketChannel(SelectorProvider provider)
SelectorProvider.public NioSocketChannel(SocketChannel socket)
SocketChannel.public NioSocketChannel(Channel parent, SocketChannel socket)
parent - the Channel which created this instance or null if it was created by the usersocket - the SocketChannel which will be usedpublic 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 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 SocketChannelisInputShutdown in class AbstractNioChannelpublic 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 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.public boolean isOutputShutdown()
isOutputShutdown in interface SocketChannelSocket.isOutputShutdown()public ChannelFuture shutdownOutput()
shutdownOutput in interface SocketChannelSocket.shutdownOutput()public ChannelFuture shutdownOutput(ChannelPromise promise)
shutdownOutput in interface SocketChannelWill notify the given {@link ChannelPromise}protected SocketAddress localAddress0()
AbstractChannelSocketAddress which is bound locally.localAddress0 in class AbstractChannelprotected SocketAddress remoteAddress0()
AbstractChannelSocketAddress which the Channel is connected to.remoteAddress0 in class AbstractChannelprotected void doBind(SocketAddress localAddress) throws Exception
AbstractChannelChannel to the SocketAddressdoBind in class AbstractChannelExceptionprotected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
AbstractNioChanneldoConnect in class AbstractNioChannelExceptionprotected void doFinishConnect()
throws Exception
AbstractNioChanneldoFinishConnect in class AbstractNioChannelExceptionprotected void doDisconnect()
throws Exception
AbstractChannelChannel from its remote peerdoDisconnect in class AbstractChannelExceptionprotected void doClose()
throws Exception
AbstractChannelChanneldoClose in class AbstractChannelExceptionprotected int doReadBytes(ByteBuf byteBuf) throws Exception
AbstractNioByteChannelByteBuf and return the amount.doReadBytes in class AbstractNioByteChannelExceptionprotected int doWriteBytes(ByteBuf buf) throws Exception
AbstractNioByteChanneldoWriteBytes in class AbstractNioByteChannelbuf - the ByteBuf from which the bytes should be writtenExceptionprotected long doWriteFileRegion(FileRegion region) throws Exception
AbstractNioByteChannelFileRegiondoWriteFileRegion in class AbstractNioByteChannelregion - the FileRegion from which the bytes should be writtenExceptionprotected void doWrite(ChannelOutboundBuffer in) throws Exception
AbstractChanneldoWrite in class AbstractNioByteChannelExceptionprotected AbstractNioChannel.AbstractNioUnsafe newUnsafe()
AbstractChannelAbstractChannel.AbstractUnsafe instance which will be used for the life-time of the ChannelnewUnsafe in class AbstractNioByteChannelCopyright © 2008–2015 The Netty Project. All rights reserved.