Skip to content

Commit 4248146

Browse files
bradfitzgopherbot
authored andcommitted
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>
1 parent faf4e97 commit 4248146

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/net/udpsock.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error) {
164164
}
165165

166166
// ReadFromUDPAddrPort acts like ReadFrom but returns a netip.AddrPort.
167+
//
168+
// If c is bound to an unspecified address, the returned
169+
// netip.AddrPort's address might be an IPv4-mapped IPv6 address.
170+
// Use netip.Addr.Unmap to get the address without the IPv6 prefix.
167171
func (c *UDPConn) ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error) {
168172
if !c.ok() {
169173
return 0, netip.AddrPort{}, syscall.EINVAL

0 commit comments

Comments
 (0)