Netty Study Summary (i)

Source: Internet
Author: User

Netty is a NIO framework that makes Java NIO a package that forms a high-performance, highly available network programming framework, many of which are based on Netty, so learning Netty is useful, and Netty itself code structure design, And some ideas are very good, for our programming can play a very good help.

First, there are several main lines of Netty:

1.server end-of-start

2.client end-of-start

Connection at 3.client end

4. Reading of messages

5. Sending of messages

Let's look at server-side startup today.

We can see that there are three major steps

Init-----Initialize Nioserversocketchannel

Register----Bind a thread to the channel, register read events, and trigger firechnnelactive and Firechannelregister events

Dobind-----Perform a true binding

To go deeper netty we need to know a few things:

1. The entire life cycle of each channel has only one Netty assigned thread to work for him, and doing so ensures that the event handling within a channel is thread-safe, especially if the processing of handler is linear, noting that Netty is assigned to the thread, If you were to restart a channel in the life cycle of a conceivable.

2.netty allocated threads may have multiple channel sharing at the same time, the Netty threading model is very simple, and there is time for me to say the thread model alone.

When a server is started, it is initialized according to the configured channel, and a configuration is made for him, such as Id,pipeline (which contains the processor chain), unsafe (some actual operations, such as the registration of a channel at the Java level). After initialization, it registers a thread for him and triggers an active event and register event to perform a Java-level binding operation.

  

Netty Study Summary (i)

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.