I am just starting out with Netty and I have a question about Channel
and ChannelHandlerContext
From what I have read so far, Channel
can be seen as an abstraction over underlying socket where IO
happens, while ChannelHandlerContext
is an object used for passing information amongst channel handlers within a channel pipeline.
Is the above accurate?
Because now I am looking at a some code base that uses Netty and examples online, I find same operations that seems to be both on Channel
and also on ChannelHandlerContext
. For example:
ctx.channel().write();
vs
ctx.write();
or
ctx.channel().alloc()
vs
ctx.alloc()
Question is, why are these similar operations defined both on Channeland also on
ChannelHandlerContext`? Are they different in any ways? Under which conditions should one be preferred over the other?
question from:
https://stackoverflow.com/questions/65936958/what-is-the-difference-between-operations-on-channel-vs-operations-on-channelhan 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…