@@ -542,12 +542,18 @@ func dialSingle(ctx context.Context, dp *dialParam, ra Addr) (c Conn, err error)
542
542
}
543
543
544
544
// Listen announces on the local network address laddr.
545
+ //
545
546
// The network net must be a stream-oriented network: "tcp", "tcp4",
546
547
// "tcp6", "unix" or "unixpacket".
547
- // For TCP and UDP, the syntax of laddr is "host:port", like "127.0.0.1:8080".
548
+ //
549
+ // For TCP, the syntax of laddr is "host:port", like "127.0.0.1:8080".
548
550
// If host is omitted, as in ":8080", Listen listens on all available interfaces
549
551
// instead of just the interface with the given host address.
550
- // See Dial for more details about address syntax.
552
+ // Listening on network "tcp" with host "0.0.0.0" or "[::]" may listen on both
553
+ // IPv4 and IPv6. To only use IPv4, use network "tcp4". To explicitly use both,
554
+ // listen on ":port" without a host.
555
+ //
556
+ // See Dial for more details about the address syntax.
551
557
//
552
558
// Listening on a hostname is not recommended because this creates a socket
553
559
// for at most one of its IP addresses.
@@ -572,12 +578,18 @@ func Listen(net, laddr string) (Listener, error) {
572
578
}
573
579
574
580
// ListenPacket announces on the local network address laddr.
581
+ //
575
582
// The network net must be a packet-oriented network: "udp", "udp4",
576
583
// "udp6", "ip", "ip4", "ip6" or "unixgram".
577
- // For TCP and UDP, the syntax of laddr is "host:port", like "127.0.0.1:8080".
578
- // If host is omitted, as in ":8080", ListenPacket listens on all available interfaces
579
- // instead of just the interface with the given host address.
580
- // See Dial for the syntax of laddr.
584
+ //
585
+ // For UDP, the syntax of laddr is "host:port", like "127.0.0.1:8080".
586
+ // If host is omitted, as in ":8080", ListenPacket listens on all available
587
+ // interfaces instead of just the interface with the given host address.
588
+ // Listening on network "udp" with host "0.0.0.0" or "[::]" may listen on both
589
+ // IPv4 and IPv6. To only use IPv4, use network "udp4". To explicitly use both,
590
+ // listen on ":port" without a host.
591
+ //
592
+ // See Dial for more details about the address syntax.
581
593
//
582
594
// Listening on a hostname is not recommended because this creates a socket
583
595
// for at most one of its IP addresses.
0 commit comments