]> Cypherpunks repositories - gostls13.git/commitdiff
net: add godoc links on UDP related symbols
authorOlivier Mengué <olivier.mengue@gmail.com>
Sun, 21 Jul 2024 13:04:38 +0000 (15:04 +0200)
committerGopher Robot <gobot@golang.org>
Mon, 22 Jul 2024 18:33:24 +0000 (18:33 +0000)
Change-Id: Ibc861e7b2aebc8fd1e0ba15d8d35ae0ecfe7747e
Reviewed-on: https://go-review.googlesource.com/c/go/+/599996
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/net/udpsock.go

index 4f8acb7fc890de72ff6505dc2a805f5e7876ddfc..56aabffa3180e4b9aa55d9f1c56b6d5e04ef9c4e 100644 (file)
@@ -27,7 +27,7 @@ type UDPAddr struct {
        Zone string // IPv6 scoped addressing zone
 }
 
-// AddrPort returns the UDPAddr a as a netip.AddrPort.
+// AddrPort returns the [UDPAddr] a as a [netip.AddrPort].
 //
 // If a.Port does not fit in a uint16, it's silently truncated.
 //
@@ -82,7 +82,7 @@ func (a *UDPAddr) opAddr() Addr {
 // recommended, because it will return at most one of the host name's
 // IP addresses.
 //
-// See func Dial for a description of the network and address
+// See func [Dial] for a description of the network and address
 // parameters.
 func ResolveUDPAddr(network, address string) (*UDPAddr, error) {
        switch network {
@@ -99,7 +99,7 @@ func ResolveUDPAddr(network, address string) (*UDPAddr, error) {
        return addrs.forResolve(network, address).(*UDPAddr), nil
 }
 
-// UDPAddrFromAddrPort returns addr as a UDPAddr. If addr.IsValid() is false,
+// UDPAddrFromAddrPort returns addr as a [UDPAddr]. If addr.IsValid() is false,
 // then the returned UDPAddr will contain a nil IP field, indicating an
 // address family-agnostic unspecified address.
 func UDPAddrFromAddrPort(addr netip.AddrPort) *UDPAddr {
@@ -117,14 +117,14 @@ type addrPortUDPAddr struct {
 
 func (addrPortUDPAddr) Network() string { return "udp" }
 
-// UDPConn is the implementation of the Conn and PacketConn interfaces
+// UDPConn is the implementation of the [Conn] and [PacketConn] interfaces
 // for UDP network connections.
 type UDPConn struct {
        conn
 }
 
 // SyscallConn returns a raw network connection.
-// This implements the syscall.Conn interface.
+// This implements the [syscall.Conn] interface.
 func (c *UDPConn) SyscallConn() (syscall.RawConn, error) {
        if !c.ok() {
                return nil, syscall.EINVAL
@@ -132,7 +132,7 @@ func (c *UDPConn) SyscallConn() (syscall.RawConn, error) {
        return newRawConn(c.fd), nil
 }
 
-// ReadFromUDP acts like ReadFrom but returns a UDPAddr.
+// ReadFromUDP acts like [UDPConn.ReadFrom] but returns a UDPAddr.
 func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *UDPAddr, err error) {
        // This function is designed to allow the caller to control the lifetime
        // of the returned *UDPAddr and thereby prevent an allocation.
@@ -153,7 +153,7 @@ func (c *UDPConn) readFromUDP(b []byte, addr *UDPAddr) (int, *UDPAddr, error) {
        return n, addr, err
 }
 
-// ReadFrom implements the PacketConn ReadFrom method.
+// ReadFrom implements the [PacketConn] ReadFrom method.
 func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error) {
        n, addr, err := c.readFromUDP(b, &UDPAddr{})
        if addr == nil {
@@ -163,11 +163,11 @@ func (c *UDPConn) ReadFrom(b []byte) (int, Addr, error) {
        return n, addr, err
 }
 
-// ReadFromUDPAddrPort acts like ReadFrom but returns a netip.AddrPort.
+// 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.
+// 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
@@ -184,7 +184,7 @@ func (c *UDPConn) ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err
 // bytes copied into b, the number of bytes copied into oob, the flags
 // that were set on the message and the source address of the message.
 //
-// The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be
+// The packages [golang.org/x/net/ipv4] and [golang.org/x/net/ipv6] can be
 // used to manipulate IP-level socket options in oob.
 func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr, err error) {
        var ap netip.AddrPort
@@ -195,7 +195,7 @@ func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *UDPAddr,
        return
 }
 
-// ReadMsgUDPAddrPort is like ReadMsgUDP but returns an netip.AddrPort instead of a UDPAddr.
+// ReadMsgUDPAddrPort is like [UDPConn.ReadMsgUDP] but returns an [netip.AddrPort] instead of a [UDPAddr].
 func (c *UDPConn) ReadMsgUDPAddrPort(b, oob []byte) (n, oobn, flags int, addr netip.AddrPort, err error) {
        if !c.ok() {
                return 0, 0, 0, netip.AddrPort{}, syscall.EINVAL
@@ -207,7 +207,7 @@ func (c *UDPConn) ReadMsgUDPAddrPort(b, oob []byte) (n, oobn, flags int, addr ne
        return
 }
 
-// WriteToUDP acts like WriteTo but takes a UDPAddr.
+// WriteToUDP acts like [UDPConn.WriteTo] but takes a [UDPAddr].
 func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error) {
        if !c.ok() {
                return 0, syscall.EINVAL
@@ -219,7 +219,7 @@ func (c *UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error) {
        return n, err
 }
 
-// WriteToUDPAddrPort acts like WriteTo but takes a netip.AddrPort.
+// WriteToUDPAddrPort acts like [UDPConn.WriteTo] but takes a [netip.AddrPort].
 func (c *UDPConn) WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (int, error) {
        if !c.ok() {
                return 0, syscall.EINVAL
@@ -231,7 +231,7 @@ func (c *UDPConn) WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (int, error)
        return n, err
 }
 
-// WriteTo implements the PacketConn WriteTo method.
+// WriteTo implements the [PacketConn] WriteTo method.
 func (c *UDPConn) WriteTo(b []byte, addr Addr) (int, error) {
        if !c.ok() {
                return 0, syscall.EINVAL
@@ -253,7 +253,7 @@ func (c *UDPConn) WriteTo(b []byte, addr Addr) (int, error) {
 // data is copied from oob. It returns the number of payload and
 // out-of-band bytes written.
 //
-// The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be
+// The packages [golang.org/x/net/ipv4] and [golang.org/x/net/ipv6] can be
 // used to manipulate IP-level socket options in oob.
 func (c *UDPConn) WriteMsgUDP(b, oob []byte, addr *UDPAddr) (n, oobn int, err error) {
        if !c.ok() {
@@ -266,7 +266,7 @@ func (c *UDPConn) WriteMsgUDP(b, oob []byte, addr *UDPAddr) (n, oobn int, err er
        return
 }
 
-// WriteMsgUDPAddrPort is like WriteMsgUDP but takes a netip.AddrPort instead of a UDPAddr.
+// WriteMsgUDPAddrPort is like [UDPConn.WriteMsgUDP] but takes a [netip.AddrPort] instead of a [UDPAddr].
 func (c *UDPConn) WriteMsgUDPAddrPort(b, oob []byte, addr netip.AddrPort) (n, oobn int, err error) {
        if !c.ok() {
                return 0, 0, syscall.EINVAL
@@ -280,9 +280,9 @@ func (c *UDPConn) WriteMsgUDPAddrPort(b, oob []byte, addr netip.AddrPort) (n, oo
 
 func newUDPConn(fd *netFD) *UDPConn { return &UDPConn{conn{fd}} }
 
-// DialUDP acts like Dial for UDP networks.
+// DialUDP acts like [Dial] for UDP networks.
 //
-// The network must be a UDP network name; see func Dial for details.
+// The network must be a UDP network name; see func [Dial] for details.
 //
 // If laddr is nil, a local address is automatically chosen.
 // If the IP field of raddr is nil or an unspecified IP address, the
@@ -304,9 +304,9 @@ func DialUDP(network string, laddr, raddr *UDPAddr) (*UDPConn, error) {
        return c, nil
 }
 
-// ListenUDP acts like ListenPacket for UDP networks.
+// ListenUDP acts like [ListenPacket] for UDP networks.
 //
-// The network must be a UDP network name; see func Dial for details.
+// The network must be a UDP network name; see func [Dial] for details.
 //
 // If the IP field of laddr is nil or an unspecified IP address,
 // ListenUDP listens on all available IP addresses of the local system
@@ -330,10 +330,10 @@ func ListenUDP(network string, laddr *UDPAddr) (*UDPConn, error) {
        return c, nil
 }
 
-// ListenMulticastUDP acts like ListenPacket for UDP networks but
+// ListenMulticastUDP acts like [ListenPacket] for UDP networks but
 // takes a group address on a specific network interface.
 //
-// The network must be a UDP network name; see func Dial for details.
+// The network must be a UDP network name; see func [Dial] for details.
 //
 // ListenMulticastUDP listens on all available IP addresses of the
 // local system including the group, multicast IP address.
@@ -345,8 +345,8 @@ func ListenUDP(network string, laddr *UDPAddr) (*UDPConn, error) {
 // chosen.
 //
 // ListenMulticastUDP is just for convenience of simple, small
-// applications. There are golang.org/x/net/ipv4 and
-// golang.org/x/net/ipv6 packages for general purpose uses.
+// applications. There are [golang.org/x/net/ipv4] and
+// [golang.org/x/net/ipv6] packages for general purpose uses.
 //
 // Note that ListenMulticastUDP will set the IP_MULTICAST_LOOP socket option
 // to 0 under IPPROTO_IP, to disable loopback of multicast packets.