Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the entry-level knowledge points of Netty

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what are the basic knowledge points of Netty". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Java NIO

Let's talk about Netty before we briefly understand the NIO of Java, because Netty also encapsulates Java NIO in order to simplify our coding.

In the field of java, Java NIO is NEW Imax O, and the other is Non-blocking Imax O. It is a synchronous and non-blocking Icano model, and it is also the basis of Icano multiplexing.

There are three very important concepts in NIO: buffer (Buffer), channel (Channel), and selector (Selector)

Buffer (Buffer) 1, basic concept

A buffer is essentially an array, and in NIO, all operations are buffer oriented. When data is read, it is read from the buffer, and when the data is written, it is also written to the buffer. All NIO data operations are operational buffers, while in the stream-oriented I _ Dot O system, the data is written directly to the Stream object.

All buffer types in NIO API inherit Buffer, and what we often use is that ByteBuffer,NIO has an implementation of the basic type of Java.

2. Basic principles

As mentioned above, the buffer is actually an array, which is actually a special array, which has some built-in mechanisms to help us read and write data, and can track and record changes in the buffer to facilitate our use.

There are three important attributes in the buffer to work together to track the changes in the state within the cache:

Position: specifies the next element index to be written or read, whose value is automatically updated by the get () / put () method, and position is initialized to 0 when a new Buffer object is created.

Limit: specify how much data still needs to be fetched (when writing to the channel from the buffer) or how much space is left to put the data (when reading from the channel into the buffer)

Capacity: specifies the maximum big data capacity that can be stored in the buffer. In fact, it specifies the size of the underlying array, or at least the capacity of the underlying array that we are allowed to use.

The relationship between the above three attributes: 0

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report