odnoklassniki / one-nio

Unconventional I/O library for Java
Apache License 2.0
648 stars 96 forks source link

Socket multicast support #38

Closed avrecko closed 5 years ago

avrecko commented 5 years ago

I find the Socket is missing join/leave multicast support. Any plans to add it? Why was this left out? Would it be fine if this gets included?

I made a quick try without native support here 65bc2aa8e577f9a06a195ebfa8cd867c1bbf744e. Would the API changed be acceptable?

apangin commented 5 years ago

Basically we didn't need this functionality so far, and there were no external requests before. This is a valuable addition though, and I'll be happy to accept the PR when ready. API looks fine. Thank you!

avrecko commented 5 years ago

Makes sense. Really liking the library. I'll add this over the weekend or next week.

avrecko commented 5 years ago

Time flies. I've taken a stab at it a while back.

For native solution. I looked at the JDK code. It is surprisingly - a lot of code. I ended up making a java solution using reflection (change fd and call join/leave). Not sold on it but can't see a simpler way of doing it.

For the moment I'll continue to use jdk MulticastSocket/Channel. One unique bonus would be to remove the address allocation on receive. But don't mind the overhead for now.

If need be. I'll revisit this and just open a pull request instead of an issue. Closing this.