diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..35410cacdc5e87f985c93a96520f5e11a5c822e4
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000000000000000000000000000000000000..32725b10bb178b5d4361e9f918d523d435c4e1b1
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1df24015fe1ee904293b893a8454cc82017c9979
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml
new file mode 100644
index 0000000000000000000000000000000000000000..02b915b85f9fb22b6e51491729131d93c18d906e
--- /dev/null
+++ b/.idea/git_toolbox_prj.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c364a09b48fb0b2296b04791099711ec51fcf382
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..cc10980db742d05bfd87f2dffcdf3028553a44bb
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..94a25f7f4cb416c083d265558da75d457237d671
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f8da3960feb06c4a85a64ab09fbd3c545c8a5245
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,181 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1706188747019
+
+
+ 1706188747019
+
+
+
+
+ 1706190216538
+
+
+
+ 1706190216538
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/netty-client/pom.xml b/netty-client/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b23916e4f18c441aeee7954babdc4b39e2e9a451
--- /dev/null
+++ b/netty-client/pom.xml
@@ -0,0 +1,26 @@
+
+
+ 4.0.0
+
+ tool.zyk
+ netty-learn
+ 1.0-SNAPSHOT
+
+
+ netty-client
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ io.netty
+ netty-all
+
+
+
\ No newline at end of file
diff --git a/netty-client/src/main/java/tool/zyk/hello/NettyHelloClient.java b/netty-client/src/main/java/tool/zyk/hello/NettyHelloClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..18318b812ffa3ac371d9e20c0b4fa42a6376172b
--- /dev/null
+++ b/netty-client/src/main/java/tool/zyk/hello/NettyHelloClient.java
@@ -0,0 +1,35 @@
+package tool.zyk.hello;
+
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import io.netty.handler.codec.string.StringEncoder;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * author: zyk
+ * datetime: 2024/1/25 21:32
+ * describe:
+ */
+public class NettyHelloClient {
+ public static void main(String[] args) throws InterruptedException {
+ new Bootstrap()
+ .group(new NioEventLoopGroup())
+ .channel(NioSocketChannel.class)
+ .handler(new ChannelInitializer() {
+ @Override
+ protected void initChannel(Channel channel) throws Exception {
+ channel.pipeline().addLast(new StringEncoder());
+ }
+ })
+ .connect("127.0.0.1", 8080)
+ .sync()
+ .channel()
+ .writeAndFlush("helloWorld"+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+ }
+}
diff --git a/netty-server/pom.xml b/netty-server/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7cd540242e7a4baf1539beda0c50bf52b16b06c6
--- /dev/null
+++ b/netty-server/pom.xml
@@ -0,0 +1,34 @@
+
+
+ 4.0.0
+
+ tool.zyk
+ netty-learn
+ 1.0-SNAPSHOT
+
+
+ netty-server
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ io.netty
+ netty-all
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+ org.projectlombok
+ lombok
+
+
+
\ No newline at end of file
diff --git a/netty-server/src/main/java/tool/zyk/hello/NettyHelloServer.java b/netty-server/src/main/java/tool/zyk/hello/NettyHelloServer.java
new file mode 100644
index 0000000000000000000000000000000000000000..614ec6ded5bbdc0f028b869457089ec5f31b69ff
--- /dev/null
+++ b/netty-server/src/main/java/tool/zyk/hello/NettyHelloServer.java
@@ -0,0 +1,40 @@
+package tool.zyk.hello;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import io.netty.handler.codec.string.StringDecoder;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * author: zyk
+ * datetime: 2024/1/25 21:24
+ * describe:
+ */
+@Slf4j
+public class NettyHelloServer {
+ public static void main(String[] args) {
+ new ServerBootstrap()
+ .group(new NioEventLoopGroup())
+ .channel(NioServerSocketChannel.class)
+ .childHandler(new ChannelInitializer() {
+ @Override
+ protected void initChannel(NioSocketChannel nioSocketChannel) throws Exception {
+ nioSocketChannel.pipeline().addLast(new StringDecoder());
+ nioSocketChannel.pipeline().addLast(new SimpleChannelInboundHandler() {
+ @Override
+ protected void channelRead0(ChannelHandlerContext channelHandlerContext, String s) throws Exception {
+ log.info("服务器获取信息了:{}", s);
+
+ }
+ });
+ }
+ })
+ .bind(8080);
+
+ }
+}
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..82098ecad16d3922eaa103dab6c77a00d6dfaf3a
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,43 @@
+
+
+ 4.0.0
+
+ tool.zyk
+ netty-learn
+ 1.0-SNAPSHOT
+ pom
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.3.3.RELEASE
+
+
+ netty-client
+ netty-server
+
+
+
+ 8
+ 8
+ UTF-8
+ 4.1.39.Final
+ 1.18.30
+
+
+
+
+ io.netty
+ netty-all
+ ${netty-all.version}
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+
+
+
+
+
\ No newline at end of file