mirror of
https://github.com/tursom/TursomServer.git
synced 2025-04-01 15:11:08 +08:00
fix bug
This commit is contained in:
parent
4fbe5236ee
commit
e8b6d29c4e
@ -16,7 +16,7 @@ object NioClient {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
private val nioThread = WorkerLoopNioThread(
|
private val nioThread = WorkerLoopNioThread(
|
||||||
"nioClient",
|
"nioClient",
|
||||||
daemon = false,
|
daemon = true,
|
||||||
workLoop = WorkerLoopHandler(AsyncProtocol)
|
workLoop = WorkerLoopHandler(AsyncProtocol)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ object NioClient {
|
|||||||
return suspendCoroutine { cont ->
|
return suspendCoroutine { cont ->
|
||||||
val channel = SocketChannel.open()!!
|
val channel = SocketChannel.open()!!
|
||||||
channel.configureBlocking(false)
|
channel.configureBlocking(false)
|
||||||
|
channel.connect(InetSocketAddress(host, port))
|
||||||
nioThread.register(channel, SelectionKey.OP_CONNECT) { key ->
|
nioThread.register(channel, SelectionKey.OP_CONNECT) { key ->
|
||||||
key.attach(AsyncProtocol.ConnectContext(cont, if (timeout > 0) AsyncNioChannel.timer.exec(timeout) {
|
key.attach(AsyncProtocol.ConnectContext(cont, if (timeout > 0) AsyncNioChannel.timer.exec(timeout) {
|
||||||
channel.close()
|
channel.close()
|
||||||
@ -37,7 +38,6 @@ object NioClient {
|
|||||||
null
|
null
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
channel.connect(InetSocketAddress(host, port))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user