1
0
mirror of https://github.com/golang/go synced 2024-11-22 14:54:46 -07:00

net: update documentation for ListenTCP, ListenUDP

Adds the missing wildcard port assignment description to ListenUDP.
Also updates the wildcard port description on ListenTCP.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/8063043
This commit is contained in:
Mikio Hara 2013-03-29 15:06:43 +09:00
parent abccf6b692
commit 245dc62ca4
4 changed files with 17 additions and 11 deletions

View File

@ -165,8 +165,8 @@ func (l *TCPListener) File() (f *os.File, err error) { return l.dup() }
// ListenTCP announces on the TCP address laddr and returns a TCP
// listener. Net must be "tcp", "tcp4", or "tcp6". If laddr has a
// port of 0, it means to listen on some available port. The caller
// can use l.Addr() to retrieve the chosen address.
// port of 0, ListenTCP will choose an available port. The caller can
// use the Addr method of TCPListener to retrieve the chosen address.
func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) {
switch net {
case "tcp", "tcp4", "tcp6":

View File

@ -272,10 +272,10 @@ func (l *TCPListener) SetDeadline(t time.Time) error {
// Closing l does not affect f, and closing f does not affect l.
func (l *TCPListener) File() (f *os.File, err error) { return l.fd.dup() }
// ListenTCP announces on the TCP address laddr and returns a TCP listener.
// Net must be "tcp", "tcp4", or "tcp6".
// If laddr has a port of 0, it means to listen on some available port.
// The caller can use l.Addr() to retrieve the chosen address.
// ListenTCP announces on the TCP address laddr and returns a TCP
// listener. Net must be "tcp", "tcp4", or "tcp6". If laddr has a
// port of 0, ListenTCP will choose an available port. The caller can
// use the Addr method of TCPListener to retrieve the chosen address.
func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) {
switch net {
case "tcp", "tcp4", "tcp6":

View File

@ -164,7 +164,10 @@ func unmarshalUDPHeader(b []byte) (*udpHeader, []byte) {
}
// ListenUDP listens for incoming UDP packets addressed to the local
// address laddr. The returned connection c's ReadFrom and WriteTo
// address laddr. Net must be "udp", "udp4", or "udp6". If laddr has
// a port of 0, ListenUDP will choose an available port.
// The LocalAddr method of the returned UDPConn can be used to
// discover the port. The returned connection's ReadFrom and WriteTo
// methods can be used to receive and send UDP packets with per-packet
// addressing.
func ListenUDP(net string, laddr *UDPAddr) (*UDPConn, error) {

View File

@ -180,10 +180,13 @@ func dialUDP(net string, laddr, raddr *UDPAddr, deadline time.Time) (*UDPConn, e
return newUDPConn(fd), nil
}
// ListenUDP listens for incoming UDP packets addressed to the
// local address laddr. The returned connection c's ReadFrom
// and WriteTo methods can be used to receive and send UDP
// packets with per-packet addressing.
// ListenUDP listens for incoming UDP packets addressed to the local
// address laddr. Net must be "udp", "udp4", or "udp6". If laddr has
// a port of 0, ListenUDP will choose an available port.
// The LocalAddr method of the returned UDPConn can be used to
// discover the port. The returned connection's ReadFrom and WriteTo
// methods can be used to receive and send UDP packets with per-packet
// addressing.
func ListenUDP(net string, laddr *UDPAddr) (*UDPConn, error) {
switch net {
case "udp", "udp4", "udp6":