{"id":18313898,"url":"https://github.com/oeljeklaus-you/nettylearning","last_synced_at":"2026-04-28T08:02:37.696Z","repository":{"id":97009799,"uuid":"157869592","full_name":"oeljeklaus-you/NettyLearning","owner":"oeljeklaus-you","description":"Learning the Netty by \u003c\u003cNetty in action\u003e\u003e , there are some demoes","archived":false,"fork":false,"pushed_at":"2018-11-22T12:47:26.000Z","size":604,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-09T12:33:32.285Z","etag":null,"topics":["netty","netty-http","netty-in-action","netty-websocket"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oeljeklaus-you.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-16T13:13:30.000Z","updated_at":"2018-11-27T08:33:09.000Z","dependencies_parsed_at":"2024-03-08T15:57:46.815Z","dependency_job_id":null,"html_url":"https://github.com/oeljeklaus-you/NettyLearning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oeljeklaus-you/NettyLearning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeljeklaus-you%2FNettyLearning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeljeklaus-you%2FNettyLearning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeljeklaus-you%2FNettyLearning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeljeklaus-you%2FNettyLearning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oeljeklaus-you","download_url":"https://codeload.github.com/oeljeklaus-you/NettyLearning/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeljeklaus-you%2FNettyLearning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32371673,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"online","status_checked_at":"2026-04-28T02:00:07.250Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["netty","netty-http","netty-in-action","netty-websocket"],"created_at":"2024-11-05T16:29:05.016Z","updated_at":"2026-04-28T08:02:37.675Z","avatar_url":"https://github.com/oeljeklaus-you.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Netty in Action\n## Netty-异步和事件驱动\n Netty 是一款异步的事件驱动的网络应用程序框架，支持快速地开发可维护的高性能的\n\n 面向协议的服务器和客户端。\n### Java网络编程\n 一般的Java网络编程:\n![一般的网络编程](img/一般的网络编程.png)\n ServerSocket上的accept()方法将会一直阻塞到一个连接建立，随后返回一个新的Socket用于客户端和服务器之间的通信。\n\n 该ServerSocket将继续监听传入的连接。\n\n BufferedReader和PrintWriter都衍生自Socket的输入输出流。前者从一个\n\n 字符输入流中读取文本，后者打印对象的格式化的表示到文本输出流。readLine()方法将会阻塞，直到在处一个由换行符或者回车符结尾的字符串被读取。\n\n 客户端的请求已经被处理 。\n \n 这段代码片段将只能同时处理一个连接，要管理多个并发客户端，需要为每个新的客户端\n   \n Socket创建一个新的Thread。\n \n 让我们考虑一下这种方案的影响。第一，在任何时候都可能有大量的线程处于休眠状态，只是等待输入或者输出数据就绪，这可能算是一种资源浪费。\n \n 第二，需要为每个线程的调用栈都分配内存，其默认值大小区间为64KB到1MB，具体取决于操作系统。\n \n 第三，即使Java虚拟机(JVM)在物理上可以支持非常大数量的线程，但是远在到达该极限之前，上下文切换所带来的开销就会带来麻烦。\n \n#### Java NIO\n 新的还是非阻塞的\n \n NIO 最开始是新的输入/输出(New Input/Output)的英文缩写，但是，该Java API已经出现足够长的时间了，\n \n 不再是“新的”了，因此，如今大多数的用户认为 NIO 代表非阻塞 I/O(Non-blocking I/O)，\n \n 而阻塞 I/O(blocking I/O)是旧的输入/输出(old input/output，OIO)。\n \n 你也可能遇到它被称为普通 I/O(plain I/O)的时候。\n \n## 第二章 开发第一个Netty服务器\n### EchoServer开发\n EchoServer进行开发,详情见代码\n### EchoClient开发\n EchoClient进行开发,详情见代码\n## 第六章 Java的序列化\n### 通过Java的序列化来进行通信\n 使用ObjectDecoder和ObjectEncoder进行解码和避免\n### 服务端开发\n 对于ObjectDecoder可能存在拆包和粘包的问题,加你设置objectSize的大小为Integer.MAX_SIZE\n### 客户端开发\n 在pipeline中添加解码和编码器\n \n## 第七章 Protobuf序列化\n### Protobuf的使用\n 使用Protobuf进行序列化,具有跨平台和语言无关,序列化后小等特点\n \n 1.安装protobuf\n   brew install protobuf\n   \n 2.编辑SubscribeReq.proto\n   ![proto示例](img/proto示例.png)\n \n 3.运行protoc命令\n   protoc -I=./ --java_out=../src/main/java/ ./SubscribeReq.proto \n### Protobuf序列化\n 使用Protobuf进行序列化,开发服务器端与客户端\n### 客户端和服务端开发\n 与第六章相似主要是解码编码起的使用\n \n## 第八章 MarShalling序列化\n### JBoss进行序列化\n MarShalling完全兼容JDK序列化,对JBoss的解码编码类库进行封装\n### 保留Java序列化的优势\n 完全兼容JDK序列化,通过Netty的Marshalling进行解编类\n### 客户端和服务端开发\n  与第六章相似主要是解码编码起的使用\n \n## 第九章 Http协议开发应用\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeljeklaus-you%2Fnettylearning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foeljeklaus-you%2Fnettylearning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeljeklaus-you%2Fnettylearning/lists"}