netty-确定客户端和服务端编解码工具
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user