From e8b6d29c4e304933c588662194827fd2c191f59e Mon Sep 17 00:00:00 2001 From: tursom Date: Thu, 16 Jul 2020 15:31:01 +0800 Subject: [PATCH] fix bug --- AsyncSocket/src/main/kotlin/cn/tursom/socket/NioClient.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AsyncSocket/src/main/kotlin/cn/tursom/socket/NioClient.kt b/AsyncSocket/src/main/kotlin/cn/tursom/socket/NioClient.kt index 4b510ea..49ba8c0 100644 --- a/AsyncSocket/src/main/kotlin/cn/tursom/socket/NioClient.kt +++ b/AsyncSocket/src/main/kotlin/cn/tursom/socket/NioClient.kt @@ -16,7 +16,7 @@ object NioClient { @JvmStatic private val nioThread = WorkerLoopNioThread( "nioClient", - daemon = false, + daemon = true, workLoop = WorkerLoopHandler(AsyncProtocol) ) @@ -29,6 +29,7 @@ object NioClient { return suspendCoroutine { cont -> val channel = SocketChannel.open()!! channel.configureBlocking(false) + channel.connect(InetSocketAddress(host, port)) nioThread.register(channel, SelectionKey.OP_CONNECT) { key -> key.attach(AsyncProtocol.ConnectContext(cont, if (timeout > 0) AsyncNioChannel.timer.exec(timeout) { channel.close() @@ -37,7 +38,6 @@ object NioClient { null })) } - channel.connect(InetSocketAddress(host, port)) } } } \ No newline at end of file