netty-确定客户端和服务端编解码工具

This commit is contained in:
2023-08-22 09:48:23 +08:00
parent eaccee2a9b
commit 86fd226c84
48 changed files with 235 additions and 2786 deletions

View File

@@ -1,10 +1,11 @@
package com.sv.netty;
import com.sv.netty.config.Constant;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.logging.LoggingHandler;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
@@ -51,6 +52,7 @@ public class ClientThread extends Thread{
bootstrap = new Bootstrap();
bootstrap.group(workerGroup);
bootstrap.channel(NioSocketChannel.class);
bootstrap.handler(new LoggingHandler());
bootstrap.option(ChannelOption.TCP_NODELAY, true);
bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
@@ -114,7 +116,7 @@ public class ClientThread extends Thread{
public void run() {
doConnect();
}
}, 1, TimeUnit.SECONDS);
}, 2, TimeUnit.SECONDS);
}
}