v0.5.4: fix: don't SO_REUSEADDR in open_sonar_udp_unicast_socket - #12
Merged
Conversation
SO_REUSEADDR in open_sonar_udp_unicast_socket meant that multiple unicast sockets could be open at the same time. This is misleading on Linux as packets only arrive in one of them at a time, seemingly the last opened socket. Avoid this confusion by removing SO_REUSEADDR from open_sonar_udp_unicast_socket. With this change, an attempt to open a second unicast socket will raise an exception instead. Also close sockets on exception during open_sonar_*_socket functions. And also update the UDP record example: It used to always open a multicast socket (which seems to also get unicast data), but now it supports choosing with --udp-mode, and verifying unicast configuration destination IP and port when passing --verify. Also update imu example in a similar way. Note on version bump: Since the intended behavior of doing two calls to open_sonar_udp_unicast_socket is not documented, changing code to raise on the second call could be seen as a breaking change. But because wlsonar has very few users, and because I don't see a use case for wanting to open multiple sockets with open_sonar_udp_unicast_socket, I'm treating it as a patch update v0.5.3 -> v0.5.4
wlkh
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See commit message.