@@ -7,7 +7,9 @@ import io.netty.channel.ChannelFuture
7
7
import io.netty.channel.ChannelHandlerContext
8
8
import io.netty.channel.ChannelInboundHandlerAdapter
9
9
import io.netty.channel.ChannelOption
10
+ import io.netty.channel.MultiThreadIoEventLoopGroup
10
11
import io.netty.channel.nio.NioEventLoopGroup
12
+ import io.netty.channel.nio.NioIoHandler
11
13
import io.netty.channel.socket.nio.NioServerSocketChannel
12
14
import io.netty.channel.socket.nio.NioSocketChannel
13
15
import io.netty.handler.logging.LogLevel
@@ -19,7 +21,7 @@ class TCPProxy {
19
21
20
22
fun start (listenPort : Int , dialHost : String , dialPort : Int ): ChannelFuture {
21
23
val future = ServerBootstrap ().apply {
22
- group(NioEventLoopGroup ( ))
24
+ group(MultiThreadIoEventLoopGroup ( NioIoHandler .newFactory() ))
23
25
channel(NioServerSocketChannel ::class .java)
24
26
childHandler(
25
27
nettyInitializer {
@@ -29,7 +31,7 @@ class TCPProxy {
29
31
serverCtx.channel().pipeline().addFirst(LoggingHandler (" server" , LogLevel .INFO ))
30
32
31
33
Bootstrap ().apply {
32
- group(NioEventLoopGroup ( ))
34
+ group(MultiThreadIoEventLoopGroup ( NioIoHandler .newFactory() ))
33
35
channel(NioSocketChannel ::class .java)
34
36
option(ChannelOption .CONNECT_TIMEOUT_MILLIS , 5 * 1000 )
35
37
handler(object : ChannelInboundHandlerAdapter () {
0 commit comments