Fix macos mdns and support macosx64
This commit is contained in:
3 files changed
+9
-7
No files matched your search
@@ -2,14 +2,15 @@
|
||||
|
||||
A Kotlin multiplatform library for mdns announcer(mdns server), only broadcast is supported,
|
||||
|
||||
Also, nmdns can be compiled to shared/static lib for other language calling, see [build.gradle.kts](build.gradle.kts)
|
||||
Also, nmdns can be compiled to shared/static lib for other language calling, see [c++ example](#cpp)
|
||||
|
||||
Supported platforms:
|
||||
1. windows64(mingwx64)
|
||||
2. linuxX64
|
||||
3. linuxArm64
|
||||
4. macosArm64
|
||||
5. jvm(11 or later)
|
||||
5. macosX64
|
||||
6. jvm(11 or later)
|
||||
|
||||
Supported srv type
|
||||
1. A
|
||||
@@ -64,7 +65,7 @@ while (true) {
|
||||
}
|
||||
```
|
||||
|
||||
# C++
|
||||
# cpp
|
||||
|
||||
```cpp
|
||||
#include <csignal>
|
||||
|
||||
+2
-1
@@ -17,7 +17,8 @@ kotlin {
|
||||
linuxArm64(),
|
||||
linuxX64(),
|
||||
mingwX64(),
|
||||
macosArm64()
|
||||
macosArm64(),
|
||||
macosX64()
|
||||
)
|
||||
jvm { compilerOptions { jvmTarget = JvmTarget.JVM_11 } }
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public actual class Socket1 internal actual constructor() {
|
||||
val addr = alloc<sockaddr_in>()
|
||||
addr.sin_family = AF_INET.convert()
|
||||
addr.sin_port = htons(port.toUShort())
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY)
|
||||
addr.sin_addr.s_addr = inet_addr(ip)
|
||||
if (bind(socket, addr.ptr.reinterpret(), sizeOf<sockaddr_in>().convert()) < 0) {
|
||||
perror("Failed to bind")
|
||||
close(socket)
|
||||
@@ -43,8 +43,8 @@ public actual class Socket1 internal actual constructor() {
|
||||
memScoped {
|
||||
val mreq = alloc<ip_mreq>()
|
||||
mreq.imr_multiaddr.s_addr = inet_addr("224.0.0.251")
|
||||
mreq.imr_interface.s_addr = htonl(INADDR_ANY)
|
||||
if (setsockopt(socket, IPPROTO_TP, IP_ADD_MEMBERSHIP, mreq.ptr, sizeOf<ip_mreq>().convert()) < 0) {
|
||||
mreq.imr_interface.s_addr = inet_addr(ip)
|
||||
if (setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq.ptr, sizeOf<ip_mreq>().convert()) < 0) {
|
||||
perror("setsockopt IP_ADD_MEMBERSHIP")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user