lemunozm / message-io

Fast and easy-to-use event-driven network library.
Apache License 2.0
1.11k stars 74 forks source link

multicast example panic (Mac) #70

Closed dabat closed 3 years ago

dabat commented 3 years ago

hi @lemunozm ! excellent work on this crate, very exciting!

just wanted to share that while i was reviewing and running some of the examples, i found this issue where the second client to attempt running the multicast example panics after connecting, with an Address already in use error.

image

lemunozm commented 3 years ago

Hi @dabat, thanks for the comment, I'm glad you like it 😃

It's really weird since on my computer this is working and this functionality is the base of termchat and anybody complains about it...

I checked the code and the reuse address is set to true correctly in multicast to avoid these issues.

Could you tell me the OS version are you using? Thanks!

lemunozm commented 3 years ago

Hi, what's the state of this issue? Did it work?

dabat commented 3 years ago

hi @lemunozm my apologies for not getting back to you, the emails were buried in my inbox. i am still seeing this error in the multicast example. image

i'm running on macOS 11.4 and i pulled latest on master branch. as you can see in the error message, thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: Os { code: 48, kind: AddrInUse, message: "Address already in use" }', examples/multicast/main.rs:23:70 this is the line that is panicing https://github.com/lemunozm/message-io/blob/7e27a039e03b80ea596ed301d5e0bf18ef442597/examples/multicast/main.rs#L23

lemunozm commented 3 years ago

Hi @dabat , thanks so much for your answer.

I made a integration test to run this use-case in CI: https://github.com/lemunozm/message-io/pull/94

As you noticed, multicast is not working in newer versions of Mac. Mac requires to add also the SO_REUSEPORT option in addition to SO_REUSEADDR.

Two interesting resources about it:

Solution overview:

net2 (used currently to enable SO_REUSEADDR) do not support SO_REUSE_PORT. Use socket2 instead that support it

lemunozm commented 3 years ago

Fixed in version 0.14.2

Since the test is already working in Mac I close the issue. If you continue having problems, feel free to reopen it.

Thanks for notifying the error!