diff --git a/cloud-common-socket/pom.xml b/cloud-common-socket/pom.xml
new file mode 100644
index 0000000..f462f45
--- /dev/null
+++ b/cloud-common-socket/pom.xml
@@ -0,0 +1,23 @@
+
+
+
+ cm-cloud
+ com.cm
+ 1.0.1-SNAPSHOT
+
+ 4.0.0
+
+ cloud-common-socket
+
+
+
+ io.netty
+ netty-all
+ 4.1.50.Final
+
+
+
+
+
\ No newline at end of file
diff --git a/cloud-common-socket/src/main/java/com/cm/socket/Client.java b/cloud-common-socket/src/main/java/com/cm/socket/Client.java
new file mode 100644
index 0000000..45600d0
--- /dev/null
+++ b/cloud-common-socket/src/main/java/com/cm/socket/Client.java
@@ -0,0 +1,74 @@
+package com.cm.socket;
+
+import com.cm.socket.decoder.MessageDecoder;
+import com.cm.socket.encoder.MessageEncoder;
+import com.cm.socket.pojo.Message;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.*;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+
+/**
+ * When you feel like quitting. Think about why you started
+ * 当你想要放弃的时候,想想当初你为何开始
+ *
+ * @ClassName: Client
+ * @Description:
+ * @Author: WangGeng
+ * @Date: 2020/7/4 18:20
+ * @Version: 1.0
+ **/
+public class Client {
+
+ public static void main(String[] args) {
+ EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
+ Bootstrap bootstrap = new Bootstrap();
+ final int[] sendCount = {0};
+ try {
+ bootstrap.group(eventLoopGroup);
+ bootstrap.channel(NioSocketChannel.class);
+ bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
+ bootstrap.handler(new ChannelInitializer() {
+ @Override
+ protected void initChannel(SocketChannel ch) throws Exception {
+ ch.pipeline().addLast(new MessageEncoder());
+ ch.pipeline().addLast(new MessageDecoder());
+ ch.pipeline().addLast(new SimpleChannelInboundHandler() {
+ @Override
+ protected void channelRead0(ChannelHandlerContext ctx, Message msg) throws Exception {
+ System.out.println(msg.getContent());
+ if(sendCount[0] < 4) {
+ Thread.sleep(5000);
+ Message message = new Message();
+ message.setStart((byte) 0x01);
+ message.setType((byte) 0x02);
+ message.setContent("你好服务器"+ sendCount[0] +"!");
+ ctx.channel().writeAndFlush(message);
+ sendCount[0]++;
+ }
+ }
+
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+ cause.printStackTrace();
+ ctx.close();
+ }
+ });
+ }
+ });
+ ChannelFuture channelFuture = bootstrap.connect("localhost", 9999).sync();
+ Message message = new Message();
+ message.setStart((byte) 0x01);
+ message.setType((byte) 0x02);
+ message.setContent("你好服务器!");
+ channelFuture.channel().writeAndFlush(message);
+ channelFuture.channel().closeFuture().sync();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ eventLoopGroup.shutdownGracefully();
+ }
+ }
+
+}
diff --git a/cloud-common-socket/src/main/java/com/cm/socket/decoder/MessageDecoder.java b/cloud-common-socket/src/main/java/com/cm/socket/decoder/MessageDecoder.java
new file mode 100644
index 0000000..1cedcfa
--- /dev/null
+++ b/cloud-common-socket/src/main/java/com/cm/socket/decoder/MessageDecoder.java
@@ -0,0 +1,52 @@
+package com.cm.socket.decoder;
+
+import com.cm.socket.pojo.Message;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import java.nio.charset.Charset;
+import java.util.List;
+
+/**
+ * When you feel like quitting. Think about why you started
+ * 当你想要放弃的时候,想想当初你为何开始
+ *
+ * @ClassName: MessageDecoder
+ * @Description: 消息解码器
+ * @Author: WangGeng
+ * @Date: 2020/7/4 16:11
+ * @Version: 1.0
+ **/
+public class MessageDecoder extends ByteToMessageDecoder {
+ /**
+ * 头部长度 1byte + 1byte + 4byte
+ */
+ private static final int HEADER_LENGTH = 6;
+
+ @Override
+ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List