NIO-dispersedaggregation application

zhaozj2021-02-16  81

Dispersion / aggregation I / O is useful for dividing data into several parts. For example, you might write a web application using a message object, each message being divided into a head and a fixed length of the fixed length. You can create a buffer that can accommodate the head and the other buffer that is just a bad body. When you put them in an array and use a dispersion reading to read messages to them, the head and body will be neatly divided into both buffers.

The aggregation write is useful for constituent a single data stream in a separate buffer. In order to be consistent with the above message example, you can use aggregated write to move the individual parts of the network message as a single data stream to transfers the message across the network.

转载请注明原文地址:https://www.9cbs.com/read-15244.html

New Post(0)