I am working on a project involving multicast UDP....
# ktor
j
I am working on a project involving multicast UDP. As far as I can tell, from the documentation and by looking through the ktor code (in particular
UDPSocketBuilder
) , there seems to be no way to create a Multicast socket in ktor. Is that correct? And if so, does anyone know if it's on a roadmap?
If you miss something, PRs awe welcome
j
Yep, that's it (or the NIO variant of that, datagram channels can join multicast groups too). I have been looking through the code to see if I could create a PR, and it doesn't seem too difficult, I'd be happy to give it a go.
🙏 1
👌 2
OK, so I started looking into this, and am trying to get the most basic 2-way UDP communication (echo server) to work, but no luck so far. The available documentation focuses mostly on TCP, as do the unit tests. Does anyone have working UDP code I could take a look at?
d
Do you have the source code?
j
Of ktor? Yes I do, but unfortunately the UDP code isn't referenced anywhere in it.
Of course it's there, it's just not used in the project itself nor in its unit tests
My next step will be to create a demo project with a straight Kotlin example of what I am trying to do, and a ktor one.
👌 1
OK I created a gist, with a working example using Threads, and a not-working example using Ktor's sockets. Note that this doesn't have anything to do with multicast yet, I'm just trying to get some basic UDP traffic going. https://gist.github.com/jorispz/8aa816c96ba15db131335946db8a9a9b
I just realised I should have used NIO in the non-ktor case, I'll update the gist
OK, gist has been upated with a NIO sample, it's hacked together so don't judge the code style 🙂
Just to close this off, I got a basic Ktor implementation working, so for now I'm good