public class NioSocketChannel extends AbstractNioByteChannel implements SocketChannel
SocketChannel
which uses NIO selector based implementation.AbstractNioByteChannel.NioByteUnsafe
AbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafe
AbstractChannel.AbstractUnsafe
Channel.Unsafe
readInterestOp
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(io.netty.buffer.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(io.netty.buffer.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 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, setOpWrite
doBeginRead, doDeregister, doRegister, eventLoop, isCompatible, isOpen, isReadPending, newDirectBuffer, newDirectBuffer, selectionKey, setReadPending, unsafe
alloc, 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, writeAndFlush
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
alloc, 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, writeAndFlush
compareTo
public 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()
Channel
parent
in interface Channel
parent
in interface SocketChannel
parent
in class AbstractChannel
null
if this channel does not have a parent channel.public ChannelMetadata metadata()
Channel
public SocketChannelConfig config()
Channel
config
in interface Channel
config
in interface SocketChannel
protected SocketChannel javaChannel()
javaChannel
in class AbstractNioChannel
public boolean isActive()
Channel
true
if the Channel
is active and so connected.public boolean isInputShutdown()
AbstractNioChannel
true
if the input of this Channel
is shutdownisInputShutdown
in interface DuplexChannel
isInputShutdown
in class AbstractNioChannel
public InetSocketAddress localAddress()
Channel
SocketAddress
is supposed to be down-cast into more concrete
type such as InetSocketAddress
to retrieve the detailed
information.localAddress
in interface Channel
localAddress
in interface SocketChannel
localAddress
in class AbstractChannel
null
if this channel is not bound.public InetSocketAddress remoteAddress()
Channel
SocketAddress
is supposed to be down-cast into more
concrete type such as InetSocketAddress
to retrieve the detailed
information.remoteAddress
in interface Channel
remoteAddress
in interface SocketChannel
remoteAddress
in class AbstractChannel
null
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 Exception
AbstractChannel
doShutdownOutput
in class AbstractChannel
Exception
public boolean isOutputShutdown()
isOutputShutdown
in interface DuplexChannel
Socket.isOutputShutdown()
public ChannelFuture shutdownOutput()
shutdownOutput
in interface DuplexChannel
Socket.shutdownOutput()
public ChannelFuture shutdownOutput(ChannelPromise promise)
shutdownOutput
in interface DuplexChannel
Will notify the given {@link ChannelPromise}
protected SocketAddress localAddress0()
AbstractChannel
SocketAddress
which is bound locally.localAddress0
in class AbstractChannel
protected SocketAddress remoteAddress0()
AbstractChannel
SocketAddress
which the Channel
is connected to.remoteAddress0
in class AbstractChannel
protected void doBind(SocketAddress localAddress) throws Exception
AbstractChannel
Channel
to the SocketAddress
doBind
in class AbstractChannel
Exception
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
AbstractNioChannel
doConnect
in class AbstractNioChannel
Exception
protected void doFinishConnect() throws Exception
AbstractNioChannel
doFinishConnect
in class AbstractNioChannel
Exception
protected void doDisconnect() throws Exception
AbstractChannel
Channel
from its remote peerdoDisconnect
in class AbstractChannel
Exception
protected void doClose() throws Exception
AbstractChannel
Channel
doClose
in class AbstractNioChannel
Exception
protected int doReadBytes(io.netty.buffer.ByteBuf byteBuf) throws Exception
AbstractNioByteChannel
ByteBuf
and return the amount.doReadBytes
in class AbstractNioByteChannel
Exception
protected int doWriteBytes(io.netty.buffer.ByteBuf buf) throws Exception
AbstractNioByteChannel
ByteBuf
to the underlying Channel
.doWriteBytes
in class AbstractNioByteChannel
buf
- the ByteBuf
from which the bytes should be writtenException
protected long doWriteFileRegion(FileRegion region) throws Exception
AbstractNioByteChannel
FileRegion
doWriteFileRegion
in class AbstractNioByteChannel
region
- the FileRegion
from which the bytes should be writtenException
protected void doWrite(ChannelOutboundBuffer in) throws Exception
AbstractChannel
doWrite
in class AbstractNioByteChannel
Exception
protected AbstractNioChannel.AbstractNioUnsafe newUnsafe()
AbstractChannel
AbstractChannel.AbstractUnsafe
instance which will be used for the life-time of the Channel
newUnsafe
in class AbstractNioByteChannel
Copyright © 2008–2017 The Netty Project. All rights reserved.