]> Cypherpunks repositories - gostls13.git/commitdiff
net: update documentation for ListenTCP, ListenUDP
authorMikio Hara <mikioh.mikioh@gmail.com>
Fri, 29 Mar 2013 06:06:43 +0000 (15:06 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Fri, 29 Mar 2013 06:06:43 +0000 (15:06 +0900)
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

src/pkg/net/tcpsock_plan9.go
src/pkg/net/tcpsock_posix.go
src/pkg/net/udpsock_plan9.go
src/pkg/net/udpsock_posix.go

index ed36646038c8a5674c99866bfedab21f25415877..517e671ac66cf5eb9dee082634b984e14307b1de 100644 (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":
index bd5a2a287754d8d6624583039cd040f71e570eec..60908c3cd09498469c5c8b07e92bb43c9008654a 100644 (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":
index 66dcbab7c5a9618e2ac85a431d0a1ff1ff544c34..4cf0ca37aa3df1b89d90672f0adcd6c62a6401d4 100644 (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) {
index 9aafb7083a7a31257aedcef4ba69f1b897668a2e..39abea210f2af0c19173b81c62609c45a1983dd8 100644 (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":