Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does netty determine when a read is complete?

Below is a ChannelHandler for a echo server.

enter image description here

Netty framework will call channelReadComplete() method to notify the handler that the last call made to channelRead() was the last message in the current batch.

My question is, since data are transferred on wire in trunks, how could Netty know when a batch of message is complete?

like image 614
smwikipedia Avatar asked Feb 12 '15 09:02

smwikipedia


1 Answers

channelReadComplete() is triggered once there is no more data to read from the underlying transport. When talking about SocketChannels this would be either of these two cases:

  1. read(...) returns 0
  2. read(...) got a buffer passed to it that has 1024 bytes to fill, but less than 1024 are filled.
like image 149
Norman Maurer Avatar answered Sep 20 '22 13:09

Norman Maurer