Skip to content

UDP: send a datagram to an IP literal, and add a v6only option - #13

Open
dominicletz wants to merge 2 commits into
cursor/tcp-ssl-ip-literal-84b4from
cursor/udp-ipv6-and-v6only-84b4
Open

dominicletz wants to merge 2 commits into
cursor/tcp-ssl-ip-literal-84b4from
cursor/udp-ipv6-and-v6only-84b4

Conversation

@dominicletz

@dominicletz dominicletz commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

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/3 takes a destination in every form Socket.Address.t() covers. A literal ("::1", "[::1]", an IPv4 literal, or a tuple) goes to :gen_udp as 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/2 takes v6only: true | false and maps it to ipv6_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 test on this branch is 22 tests, 0 failures (Elixir 1.14.0 / OTP 25). mix format --check-formatted passes.

Open in Web Open in Cursor 

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants