I am implementing a custom FTP protocol using netty. However, to get started I will have the server just send the length of the file, followed by the file contents. To do this I am following the FileServer.java and the FileServerHandler.java example that comes with netty. However, I have a few questions in regards to how netty handles events intended to be handle by just one handler when there are many handlers in the channel pipeline. For example, consider FileServer.java and the FileServerHandler.java
FileServer.java
p.addLast(
new StringEncoder(CharsetUtil.UTF_8),
new LineBasedFrameDecoder(8192),
new StringDecoder(CharsetUtil.UTF_8),
new ChunkedWriteHandler(),
new FileServerHandler());
In the example all server outbound events will propagate in the following order through the channel pipeline
However, the server sends a string to the client requesting the name of the file to send. My questions are:
The NETTY API is not clear on this, is the String ignored by the ChunkedWriterHandler and sent to the String encoder? If so, how is it discarded? I looked at the ChunkedWriterHandler code and I did notice a discard method, but I am unsure if this applies to this scenario:
discard method inside ChunkedWriterHandler Object message = currentWrite.msg; if (message instanceof ChunkedInput) { ChunkedInput in = (ChunkedInput) message; try { //Do something; } else{ Closed Channel Exception }
In addition, once the chunkedWriterHandler starts processing and sending chunkedInput through the channel pipeline, how does the StringEncoder handle chunkedInput? Does it ignore it (if so, how?) and just forwards it to the next handler, however in this case there are no further handlers so does it just writes the data to the socket or add it to a queue if flush was not called after write?
How does any Encoder write data to the socket? in many of the netty examples: Telnet (StringEncoder), factorial (NumberEncoder), etc., the encoder just writes the String or int to a ByteBuf, BUT WHERE IN THE ENCODER CODE IS THE ByteBuf actually written and flushed to the socket/wire?
--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/715a1b70-a8d6-49b3-ad63-f701fd90d43e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.