Giter Club home page Giter Club logo

io-learning's Introduction

Java网络编程系统学习

参考资料:《Netty权威指南》

IO入门

BIO

  • 为每个客户端连接创建一个新的线程
  • 客户端个数:IO线程数 = 1:1
  • 同步阻塞

伪异步IO

  • 使用线程池
  • 客户端个数:IO线程数 = M:N(M>>N)
  • 同步阻塞

NIO

  • Selector 多路复用器(选择器)
  • 客户端个数:IO线程数 = M:1
  • 同步非阻塞

AIO

  • NIO2.0新增异步套接字通道
  • 异步非阻塞
  • 客户端个数:IO线程数 = M:0 (不需要额外的IO线程,被动回调)

Netty

  • Netty是NIO框架

粘包和拆包

  • LineBasedFrameDecoder是以换行符为结束标志的解码器
  • DelimiterBasedFrameDecoder用于使用指定分隔符分割的消息解码
  • FixedLengthFrameDecoder用于固定长度的消息解码

编码与解码

编码解码技术选型要点

  • 是否跨语言
  • 编码后的大小
  • 编解码的性能
  • API是否方便,开发者工作量

常用编解码框架技术

Protobuf

  • 结构化数据存储格式
  • 高效的解码编码性能
  • 跨语言,官方支持Java、C++、Python
  • 使用数据描述文件对数据结构进行说明,代码生成机制

Thrift

适用于静态的数据交换,需要先确定好它的数据结构,数据结构发生变化时,必须重新编辑IDL文件,编译生成代码

  • 主要组成部分:语言系统与IDL编辑器、TProtocol、TTransport、TProcessor、TServer

JBoss Marshalling

  • 更多是在JBoss内部使用

MessagePack编码解码器

ProtoBuf解码编码器

HTTP协议开发

WebSocket协议开发

协议特点

  • 单一的TCP连接,全双工通信模式
  • 无头部信息、Cookie和身份认证、安全开销
  • 通过ping/pong帧保持链路激活

私有协议开发

io-learning's People

Contributors

equator8848 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.