jsMain.com.ditchoom.socket.ReadStats.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of socket-js Show documentation
Show all versions of socket-js Show documentation
Simple multiplatform kotlin coroutines based socket.
package com.ditchoom.socket
import kotlinx.coroutines.asDeferred
import kotlin.js.Promise
actual suspend fun readStats(port: UShort, contains: String): List {
if (TcpPortUsed.check(port.toInt(), "127.0.0.1").asDeferred().await()) {
return listOf("TCP CHECK FAIL PORT: $port")
}
return emptyList()
}
@JsModule("tcp-port-used")
@JsNonModule
external class TcpPortUsed {
companion object {
fun check(port: Int, address: String): Promise
}
}