public class NetChannel extends AttributeChannel<NetChannel> implements NetDuplexChannel<NetChannel>
| 限定符和类型 | 字段和说明 |
|---|---|
protected net.hasor.neta.channel.SoAsyncChannel |
channel |
protected net.hasor.cobble.concurrent.future.Future<NetChannel> |
closeFuture |
protected AtomicBoolean |
closeStatus |
protected net.hasor.neta.channel.SoContextImpl |
context |
protected PipeContextImpl |
pipeCtx |
protected Pipeline<ByteBuf> |
pipeline |
protected net.hasor.neta.channel.SoRcvCompletionHandler |
rHandler |
protected net.hasor.neta.channel.SoSndContext |
wContext |
protected net.hasor.neta.channel.SoSndCompletionHandler |
wHandler |
| 限定符和类型 | 方法和说明 |
|---|---|
net.hasor.cobble.concurrent.future.Future<NetChannel> |
close()
close this channel.
|
net.hasor.cobble.concurrent.future.Future<NetChannel> |
closeNow()
close this channel now.
|
<T> T |
findPipeContext(Class<T> serviceType)
Get the attachment for
PipeContext |
net.hasor.cobble.concurrent.future.Future<NetChannel> |
flush()
flash
|
net.hasor.cobble.concurrent.future.Future<?> |
flush(String pipeName)
sent data to remote, The network IO transfer operation is performed asynchronously.
|
long |
getChannelID()
channel id
|
SoContext |
getContext()
get context
|
long |
getCreatedTime()
channel accept time
|
long |
getLastActiveTime()
The last time data was received or sent
|
long |
getLastRcvTime()
last received data time
|
long |
getLastSndTime()
last sent data time
|
NetListen |
getListen()
Returns the
NetListen that accepts this channel |
SocketAddress |
getLocalAddr()
local
SocketAddress |
int |
getRcvBufferSize()
Returns the received buffer size.
|
int |
getRcvBufferUsed()
Returns the size of the received buffer used.
|
long |
getRcvBytes()
Number of bytes received
|
SoHandlerStatus |
getRcvHandlerStatus()
Returns the receiving Handler state
|
int |
getRcvSlotSize()
Returns the number of pipeline received slots.
|
SocketAddress |
getRemoteAddr()
get remote address of the channel
|
int |
getSndBufferSize()
Returns the send buffer size.
|
int |
getSndBufferUsed()
Returns the size of the send buffer used.
|
long |
getSndBytes()
Number of bytes send
|
SoHandlerStatus |
getSndHandlerStatus()
Returns the send Handler state
|
int |
getSndSlotSize()
Returns the number of pipeline send slots.
|
void |
ignoreReadEofFlag()
When shutdownOutput is called remotely, an end of read flag was encountered, which usually means closing the channel.
|
protected void |
initChannel(PipeContextImpl pipeContext,
Pipeline<ByteBuf> pipeline) |
boolean |
isClient()
a connect
NetChannel |
boolean |
isClose()
return close status.
|
boolean |
isListen()
|
boolean |
isServer()
an accept
NetChannel |
boolean |
isShutdownInput()
Returns whether the read channel is closed.
|
boolean |
isShutdownOutput()
Returns whether the write channel is closed.
|
void |
printStackTrace()
Prints this pipline status and its backtrace to the System.out.
|
void |
printStackTrace(PrintStream s)
Prints this pipline status and its backtrace to the specified print stream.
|
net.hasor.cobble.concurrent.future.Future<?> |
sendData(Object writeData)
sent data to remote, The network IO transfer operation is performed asynchronously.
|
net.hasor.cobble.concurrent.future.Future<NetChannel> |
sendData(Object writeData,
String pipeName)
sent data to remote, The network IO transfer operation is performed asynchronously.
|
void |
setReadTimeout()
Sets a timer that will fire readTimeout if no network data is received within a specified amount of time.
|
void |
setReadTimeout(int timeout,
TimeUnit unit)
Sets a timer that will fire readTimeout if no network data is received within a specified amount of time.
|
void |
shutdownInput()
Shutdown the connection for reading without closing the channel.
|
void |
shutdownOutput()
Shutdown the connection for write without closing the channel.
|
void |
waitReceive()
expect new data to be received within SoReadTimeoutMs
|
void |
waitReceive(int timeout,
TimeUnit unit)
expect new data to be received within timeout.
|
getAttribute, setAttributeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAttribute, setAttributeprotected final net.hasor.neta.channel.SoAsyncChannel channel
protected final net.hasor.neta.channel.SoSndContext wContext
protected final net.hasor.neta.channel.SoContextImpl context
protected final net.hasor.neta.channel.SoRcvCompletionHandler rHandler
protected final net.hasor.neta.channel.SoSndCompletionHandler wHandler
protected PipeContextImpl pipeCtx
protected final AtomicBoolean closeStatus
protected final net.hasor.cobble.concurrent.future.Future<NetChannel> closeFuture
protected void initChannel(PipeContextImpl pipeContext, Pipeline<ByteBuf> pipeline)
public long getChannelID()
SoChannelgetChannelID 在接口中 SoChannel<NetChannel>public boolean isListen()
SoChannelisListen 在接口中 SoChannel<NetChannel>public long getCreatedTime()
SoChannelgetCreatedTime 在接口中 SoChannel<NetChannel>public long getLastActiveTime()
SoChannelgetLastActiveTime 在接口中 SoChannel<NetChannel>public long getLastSndTime()
public long getLastRcvTime()
public SoHandlerStatus getRcvHandlerStatus()
public SoHandlerStatus getSndHandlerStatus()
public boolean isServer()
SoChannelNetChannelisServer 在接口中 SoChannel<NetChannel>public boolean isClient()
SoChannelNetChannelisClient 在接口中 SoChannel<NetChannel>public boolean isShutdownInput()
NetDuplexChannelisShutdownInput 在接口中 NetDuplexChannel<NetChannel>public void ignoreReadEofFlag()
NetDuplexChannelWhen shutdownOutput is called remotely, an end of read flag was encountered, which usually means closing the channel. But the remote still has the ability to receive data.
so use NetDuplexChannel.ignoreReadEofFlag() method, keep the channel state and continue to send data
Once NetDuplexChannel.ignoreReadEofFlag() is activated, the release of remote connections needs to be managed manually,
leading to NetChannel leakage if not released in time
ignoreReadEofFlag 在接口中 NetDuplexChannel<NetChannel>public void shutdownInput()
NetDuplexChannelshutdownInput 在接口中 NetDuplexChannel<NetChannel>public boolean isShutdownOutput()
NetDuplexChannelisShutdownOutput 在接口中 NetDuplexChannel<NetChannel>public void shutdownOutput()
NetDuplexChannelshutdownOutput 在接口中 NetDuplexChannel<NetChannel>public SocketAddress getLocalAddr()
SoChannelSocketAddressgetLocalAddr 在接口中 SoChannel<NetChannel>public SocketAddress getRemoteAddr()
SoChannelgetRemoteAddr 在接口中 SoChannel<NetChannel>public SoContext getContext()
SoChannelgetContext 在接口中 SoChannel<NetChannel>public <T> T findPipeContext(Class<T> serviceType)
SoChannelPipeContextfindPipeContext 在接口中 SoChannel<NetChannel>public boolean isClose()
SoChannelisClose 在接口中 SoChannel<NetChannel>public net.hasor.cobble.concurrent.future.Future<NetChannel> close()
SoChannelThe SoChannel.closeNow() and SoChannel.close() methods are valid if they are called first
close 在接口中 SoChannel<NetChannel>public net.hasor.cobble.concurrent.future.Future<NetChannel> closeNow()
SoChannelcloseNow 在接口中 SoChannel<NetChannel>public long getRcvBytes()
public long getSndBytes()
public int getRcvBufferSize()
public int getSndBufferSize()
public int getRcvBufferUsed()
public int getSndBufferUsed()
public int getRcvSlotSize()
public int getSndSlotSize()
public net.hasor.cobble.concurrent.future.Future<?> sendData(Object writeData)
data goes through the application layer network protocol stack
public net.hasor.cobble.concurrent.future.Future<NetChannel> sendData(Object writeData, String pipeName)
data goes through the application layer network protocol stack
public net.hasor.cobble.concurrent.future.Future<NetChannel> flush()
public net.hasor.cobble.concurrent.future.Future<?> flush(String pipeName)
data goes through the application layer network protocol stack
public void setReadTimeout()
public void setReadTimeout(int timeout,
TimeUnit unit)
public void waitReceive()
throws InterruptedException,
SoReadTimeoutException
public void waitReceive(int timeout,
TimeUnit unit)
throws InterruptedException,
SoReadTimeoutException
public void printStackTrace()
public void printStackTrace(PrintStream s)
s - PrintStream to use for outputCopyright © 2022–2024. All rights reserved.