fun main() = runBlocking {
val selectorManager = SelectorManager(<http://Dispatchers.IO|Dispatchers.IO>)
val serverSocket = aSocket(selectorManager).udp().bind(InetSocketAddress("127.0.0.1", 9002))
for (datagram in serverSocket.incoming) {
serverSocket.outgoing.send(
Datagram(
BytePacketBuilder().apply { append("Hello client") }.build(),
datagram.address
)
)
}
}
s
Sean Proctor
12/14/2022, 3:21 PM
I'm trying to write the client. There's a server listening on port 3702. I need to broadcast 3702 and the server will respond on the source port of the broadcast.
The probe gets sent to IP 239.255.255.250 (per the SOAP discovery spec) and the response is from 192.168.0.209 (the IP address of the device I'm probing) or multiple IP addresses if multiple devices respond.
Sean Proctor
12/14/2022, 4:34 PM
Thanks, I figured it out. Your comment eventually led me in the correct direction. I needed to use the
localAddress
from the socket sending the probe. you can see the final result on github.