public class NetChannel extends AttributeChannel<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.SoSndContext |
wContext |
| 限定符和类型 | 方法和说明 |
|---|---|
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
|
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.
|
NetListen |
getSource()
Returns the
NetListen that accepts this channel |
void |
ignoreReadEofFlag()
When shutdownOutput is called remotely, an end of read flag was encountered, which usually means closing the channel.
|
protected void |
initPipe(PipeContextImpl pipeContext,
Pipeline<?> 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.
|
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, 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 PipeContextImpl pipeCtx
protected final AtomicBoolean closeStatus
protected final net.hasor.cobble.concurrent.future.Future<NetChannel> closeFuture
protected void initPipe(PipeContextImpl pipeContext, Pipeline<?> pipeline)
public long getChannelID()
SoChannelpublic boolean isListen()
SoChannelpublic long getCreatedTime()
SoChannelpublic long getLastActiveTime()
SoChannelpublic long getLastSndTime()
public long getLastRcvTime()
public boolean isServer()
SoChannelNetChannelpublic boolean isClient()
SoChannelNetChannelpublic boolean isShutdownInput()
public void ignoreReadEofFlag()
When 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 ignoreReadEofFlag() method, keep the channel state and continue to send data
Once ignoreReadEofFlag() is activated, the release of remote connections needs to be managed manually,
leading to NetChannel leakage if not released in time
public void shutdownInput()
public SoHandlerStatus getRcvHandlerStatus()
public boolean isShutdownOutput()
public void shutdownOutput()
public SoHandlerStatus getSndHandlerStatus()
public SocketAddress getLocalAddr()
SoChannelSocketAddresspublic SocketAddress getRemoteAddr()
SoChannelpublic <T> T findPipeContext(Class<T> serviceType)
SoChannelPipeContextpublic boolean isClose()
SoChannelpublic net.hasor.cobble.concurrent.future.Future<NetChannel> close()
SoChannelThe SoChannel.closeNow() and SoChannel.close() methods are valid if they are called first
public net.hasor.cobble.concurrent.future.Future<NetChannel> closeNow()
SoChannelpublic 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
Copyright © 2022–2024. All rights reserved.