aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2022-07-26 13:29:16 -0700
committerGopher Robot <gobot@golang.org>2022-07-27 15:04:58 +0000
commit424814615491c604e6a0945f33e5a7b779dc2be5 (patch)
treeb8ab9ca890b0b59eb7eef6c6df10d74de3bf64e0
parentfaf4e97200df9415d55b04924ce77599f9e6fdfa (diff)
downloadgo-424814615491c604e6a0945f33e5a7b779dc2be5.tar.gz
go-424814615491c604e6a0945f33e5a7b779dc2be5.zip
net: document UDPConn.ReadFromUDPAddrPort's AddrPort result more
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>
-rw-r--r--src/net/udpsock.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/net/udpsock.go b/src/net/udpsock.go
index 6d29a39edf..e30624dea5 100644
--- a/src/net/udpsock.go
+++ b/src/net/udpsock.go
@@ -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