Remove ktor-network dependency use native socket
This commit is contained in:
21 files changed
+649
-179
No files matched your search
@@ -6,6 +6,6 @@
|
||||
|
||||
package cn.rtast.nmdns
|
||||
|
||||
actual fun sleep1(time: Int) {
|
||||
public actual fun sleep1(time: Int) {
|
||||
Thread.sleep(time * 1000L)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright © 2025 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 9/30/25
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.nmdns
|
||||
|
||||
import java.net.DatagramPacket
|
||||
import java.net.InetAddress
|
||||
import java.net.InetSocketAddress
|
||||
import java.net.MulticastSocket
|
||||
|
||||
public actual class Socket1 internal actual constructor() {
|
||||
private lateinit var socket: MulticastSocket
|
||||
private val group: InetAddress = InetAddress.getByName("224.0.0.251")
|
||||
|
||||
public actual fun bind(ip: String, port: Int): Socket1 {
|
||||
socket = MulticastSocket(InetSocketAddress(ip, port))
|
||||
socket.joinGroup(group)
|
||||
return this
|
||||
}
|
||||
|
||||
public actual fun send(packet: ByteArray) {
|
||||
socket.send(DatagramPacket(packet, packet.size, group, 5353))
|
||||
}
|
||||
|
||||
public actual fun destroy() {
|
||||
socket.close()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user