Commit 245dc62c authored by Mikio Hara's avatar Mikio Hara

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
parent abccf6b6
...@@ -165,8 +165,8 @@ func (l *TCPListener) File() (f *os.File, err error) { return l.dup() } ...@@ -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 // ListenTCP announces on the TCP address laddr and returns a TCP
// listener. Net must be "tcp", "tcp4", or "tcp6". If laddr has a // 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 // port of 0, ListenTCP will choose an available port. The caller can
// can use l.Addr() to retrieve the chosen address. // use the Addr method of TCPListener to retrieve the chosen address.
func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) { func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) {
switch net { switch net {
case "tcp", "tcp4", "tcp6": case "tcp", "tcp4", "tcp6":
......
...@@ -272,10 +272,10 @@ func (l *TCPListener) SetDeadline(t time.Time) error { ...@@ -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. // 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() } 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. // ListenTCP announces on the TCP address laddr and returns a TCP
// Net must be "tcp", "tcp4", or "tcp6". // listener. Net must be "tcp", "tcp4", or "tcp6". If laddr has a
// If laddr has a port of 0, it means to listen on some available port. // port of 0, ListenTCP will choose an available port. The caller can
// The caller can use l.Addr() to retrieve the chosen address. // use the Addr method of TCPListener to retrieve the chosen address.
func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) { func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) {
switch net { switch net {
case "tcp", "tcp4", "tcp6": case "tcp", "tcp4", "tcp6":
......
...@@ -164,7 +164,10 @@ func unmarshalUDPHeader(b []byte) (*udpHeader, []byte) { ...@@ -164,7 +164,10 @@ func unmarshalUDPHeader(b []byte) (*udpHeader, []byte) {
} }
// ListenUDP listens for incoming UDP packets addressed to the local // 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 // methods can be used to receive and send UDP packets with per-packet
// addressing. // addressing.
func ListenUDP(net string, laddr *UDPAddr) (*UDPConn, error) { func ListenUDP(net string, laddr *UDPAddr) (*UDPConn, error) {
......
...@@ -180,10 +180,13 @@ func dialUDP(net string, laddr, raddr *UDPAddr, deadline time.Time) (*UDPConn, e ...@@ -180,10 +180,13 @@ func dialUDP(net string, laddr, raddr *UDPAddr, deadline time.Time) (*UDPConn, e
return newUDPConn(fd), nil return newUDPConn(fd), nil
} }
// ListenUDP listens for incoming UDP packets addressed to the // ListenUDP listens for incoming UDP packets addressed to the local
// local address laddr. The returned connection c's ReadFrom // address laddr. Net must be "udp", "udp4", or "udp6". If laddr has
// and WriteTo methods can be used to receive and send UDP // a port of 0, ListenUDP will choose an available port.
// packets with per-packet addressing. // 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) { func ListenUDP(net string, laddr *UDPAddr) (*UDPConn, error) {
switch net { switch net {
case "udp", "udp4", "udp6": case "udp", "udp4", "udp6":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment