NIO family Glance

A, Buffer buffer

Basic processing unit of the user data, the client sending and receiving data need be forwarded Buffer

 

Two, Channel Channel

Similar stream; but unlike IN / OUT Stream; stream having exclusive and one-way; flow channel is biased in favor of the diversity of data

 

Three, Selectors Selector

Distributed processing client for all events

 

Four, Charset extension

Charset Character Encoding: encryption, decryption

Natively supported, the data channel level data processing, may be used for data transmission level data encryption and decryption operations

 

Five, NIO-Buffer

Buffer include

ByteBuffer、CharBuffer、ShortBuffer、IntBuffer、LongBuffer、FloatBuffer、DoubleBuffer

Unlike traditional, write data is written to Buffer-> Channel; on the contrary read

Unlike traditional, write data is written to Buffer-> Channel; on the contrary read

Provide the basis for the data block NIO press operations "block" for transmission

A Buffer represents a "block" of data

 

 

Six, NIO-Channel

Can be obtained from the channel data may be output to the data channel; perform the "block" Buffer

Asynchronously write data can be complicated (but when the data is ordered, if the intermediate multithreading added other data, may lead to unusable data. Therefore, a normal read is a thread, a thread is writing)

Buffer read data read and write data, you must write data Buffer

包括:FileChannel、SocketChannel、DatagramChannel等

 

Seven, NIO duties

 

First of all, readable to register Channel Selector, writable state

When the client sends a message to the server, the card receives message, Channel in the readable state, notified Selector, Channel message is received, among the read data to the Buffer

Published 174 original articles · won praise 115 · views 830 000 +

Guess you like

Origin blog.csdn.net/nicolelili1/article/details/103982797