Netty3 source code Analysis-socket binding implementation principle

Source: Internet
Author: User


The previous focus on the Netty adoption of the pipeline processing mode of organization, Channelhandler How to manage, channel status, channel events, such as the upper layer of the architecture design, then how to implement such as socket binding, connection, close and so on, such as the bottom of the operation of the Netty? Not only to apply the API to write programs, but the details superficial understanding. Here the implementation of the socket bindings in the channel under Oio mode is roughly traced, and the logic is the same in the case of NIO (after analysis), but it is different in the place of the thread model. The general process is as follows (detailed source comments, see my GitHub):1. We will provide the corresponding ChannelFactory when we start the client or server through bootstrap;2. In this factory construction process will get the corresponding external resources, and initialize the underlying Channelsink object, otherwise a pipeline default sink is Discardingchannelsink no public;the binding method of 3.Bootstrap opens the channel and then invokes the Bind method of the channel;4. The binding method finally agrees to be completed by the channels auxiliary class;The 4.channels.bind constructs a state event according to the value, and sends it to the bottom downstreamhandler;4. These commands will eventually be completed by the specific channelsink, because the specific channel maintains the Java socket and the input/output stream, so here is the true socket binding.





Netty3 source code Analysis-socket binding implementation principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.