]> Cypherpunks repositories - gostls13.git/commitdiff
net: document UDPConn.ReadFromUDPAddrPort's AddrPort result more
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 26 Jul 2022 20:29:16 +0000 (13:29 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 27 Jul 2022 15:04:58 +0000 (15:04 +0000)
Clarify the form of its IPv4 addresses when listening on an
unspecified address.

(found while testing/reviewing CL 399454)

Change-Id: I62b367f5a4e6d340eb72dd7ec342080f1821e63e
Reviewed-on: https://go-review.googlesource.com/c/go/+/419614
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

src/net/udpsock.go

index 6d29a39edfcfcb389401e6bba22841a5f6605390..e30624dea5a74e6a6db33c3dec5076ee00d22a99 100644 (file)
@@ -164,6 +164,10 @@ func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error) {
 }
 
 // ReadFromUDPAddrPort acts like ReadFrom but returns a netip.AddrPort.
+//
+// If c is bound to an unspecified address, the returned
+// netip.AddrPort's address might be an IPv4-mapped IPv6 address.
+// Use netip.Addr.Unmap to get the address without the IPv6 prefix.
 func (c *UDPConn) ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error) {
        if !c.ok() {
                return 0, netip.AddrPort{}, syscall.EINVAL