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
1. FileServerHandler
2. ChunkedWriteHandler
3. StringEncoder
However, the server sends a string to the client requesting the name of the
file to send.* My questions are: *
1. How does ChunkedWriterHandler handle the String since
ChunkedWriterHandler is expecting a chunkedInput specifically a
ChunkedFile?
2.
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 }
3.
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?
4.
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/netty/555cfad7-4968-4501-8458-d6c8753fb2ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.