dceb9953af64c161e1fb8a41912c039c69cd924a
T
native-mdns
A Kotlin multiplatform library for mdns announcer(mdns server), only broadcast is supported, it depends on ktor-network.About
Also, nmdns can be compiled to shared/static lib for other language calling, see build.gradle.kts
Supported platforms:
- windows64(mingwx64)
- linuxX64
- linuxArm64
- macosArm64
- jvm(11 or later)
Supported srv type
- A
- PTR
AAAA is not supported
AirPlay2(_airplay._tcp.local.) is tested
How to use
Add maven repository
repositories {
mavenCentral()
maven("https://repo.maven.rtast.cn/releases")
}
Add dependency
kotlin {
linuxX64()
// Add other platforms
sourceSets {
commonMain.dependencies {
implementation("cn.rtast.nmdns:native-mdns:0.0.2")
}
}
}
There is a simple airplay2 service
val service = registerService(
serviceType = "_airplay._tcp.local.",
serviceName = "AP@RTAST",
hostname = "rtakland.local.",
ipAddress = "192.168.10.104",
port = 7001,
bindAddress = "192.168.10.104",
mdnsPort = 5356,
txtRecords = listOf("key1=value1", "key2=value2")
)
while (true) {
service.broadcast()
delay(2000L) // or use cn.rtast.nmdns.sleep1(2) sleep 2 seconds
}
Languages
Kotlin
92%
C
8%