Repository navigation
UDP: send a datagram to an IP literal, and add a v6only option - #13
Open
dominicletz wants to merge 2 commits into
Open
dominicletz wants to merge 2 commits into
dominicletz wants to merge 2 commits into
Conversation
Socket.Datagram.send/3 takes a destination address in every form Socket.Address.t() covers, and a literal goes to :gen_udp as a tuple. Two things follow. The bracketed form a URI or a Host header carries, "[::1]", now reaches its peer. And a destination given as a literal costs no name resolution, on any datagram.
open/2 takes `v6only: true | false` and maps it to the socket's ipv6_v6only. It is the last IPv6 setting the wrapper could not spell, and an option it does not know raises rather than passes through. It matters beyond the socket: an IPv6 socket that also accepts IPv4 receives from those peers under ::ffff:a.b.c.d, and every protocol message that writes a peer address then carries that form. Only the socket can be told otherwise.
This was referenced Nov 2, 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.
Rebase of #9 onto the rebased #8, which is #12. The address-parser commit #9 was stacked on already landed as #7.
Two commits, same as the original:
Socket.Datagram.send/3takes a destination in every formSocket.Address.t()covers. A literal ("::1","[::1]", an IPv4 literal, or a tuple) goes to:gen_udpas a tuple, so a bracketed address from a URI reaches its peer and a literal costs no resolver round trip. A host name is still resolved.Socket.UDP.open/2takesv6only: true | falseand maps it toipv6_v6only. An IPv6 socket that also accepts IPv4 reports those peers as::ffff:a.b.c.d. This is the switch that refuses them.This does not call the TCP or SSL connect path. It sits on #12 because this PR and #11 both append to
test/ipv6_test.exs, and stacking them keeps each diff to its own commits. Merge #12, then this, then #11.mix teston this branch is 22 tests, 0 failures (Elixir 1.14.0 / OTP 25).mix format --check-formattedpasses.Note
Low Risk
Localized networking behavior aligned with existing TCP/SSL address parsing; new option is opt-in with tests.
Reviewed by Cursor Bugbot for commit 3ef74f4. Configure here.