fuzhengwei / fuzhengwei/blog.github.io
netty案例,netty4.1基础入门篇四《NettyServer收发数据》 - bugstack虫洞栈
- Dominant language
- HTML
- Stars
- 14
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
https://fuzhengwei.github.io/itstack-demo-netty-1/2019/08/07/netty%E6%A1%88%E4%BE%8B-netty4.1%E5%9F%BA%E7%A1%80%E5%85%A5%E9%97%A8%E7%AF%87%E5%9B%9B-NettyServer%E6%94%B6%E5%8F%91%E6%95%B0%E6%8D%AE.html
前言介绍
本章节主要介绍服务端在收到数据后,通过writeAndFlush发送ByteBuf字节码向客户端传输信息。因为我们使用客户端模拟器的编码是GBK格式,所以代码中也需要将字节码转换为GBK,否则会乱码。
开发环境
1、jdk1.8【jdk1.7以下只能部分支持netty】
2、Netty4.1.36.Final【netty3.x 4.x 5每次的变化较大,接口类名也随着变化】
3、telnet 测试【可以现在你的win7机器上测试这个命令,用于链接到服务端的测试命令】
代码示例
itstack-demo-netty-1-04
└── src
├── main
│ └── java
│ └── org.itstack.demo.netty.server
│ ├── MyChannelInitializer.java
│ ├── MyServerHandler.java
│ └── NettyServer.java
└── test
└── java
└── org.itstack.demo.netty.test
└── ApiTest.java
MyChannelInitializer.java
Contributor guide
No contributing guide indexed for this repository
Research direction
Read the linked article and inspect the Netty example under src/main/java/org/itstack/demo/netty/server, especially MyChannelInitializer.java, MyServerHandler.java, and NettyServer.java. Run ApiTest.java and use telnet as described to reproduce the behavior, but the issue does not state which failure to fix or what completion should look like.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100