]> Cypherpunks repositories - gostls13.git/commitdiff
net: update documentation for TCPConn, TCPListener and related stuff
authorMikio Hara <mikioh.mikioh@gmail.com>
Sun, 31 Mar 2013 07:47:26 +0000 (16:47 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Sun, 31 Mar 2013 07:47:26 +0000 (16:47 +0900)
Closes the API documentation gap between platforms.
Also makes the code textual representation same between platforms.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8147043

src/pkg/net/tcpsock.go
src/pkg/net/tcpsock_plan9.go
src/pkg/net/tcpsock_posix.go

index 27db1156865cb5c87c057afb93b3a905386b9484..4d9ebd214e0e2986b6215138c30166cdb165c7a8 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// TCP sockets
-
 package net
 
 // TCPAddr represents the address of a TCP end point.
index 517e671ac66cf5eb9dee082634b984e14307b1de..96cbcc246b2cc8b4fc06051b9ed23503b5c4735b 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// TCP sockets for Plan 9
-
 package net
 
 import (
index 60908c3cd09498469c5c8b07e92bb43c9008654a..8133ca1c118b3b5aa180fb413901717ecf303a80 100644 (file)
@@ -4,8 +4,6 @@
 
 // +build darwin freebsd linux netbsd openbsd windows
 
-// TCP sockets
-
 package net
 
 import (
@@ -58,8 +56,8 @@ func (a *TCPAddr) toAddr() sockaddr {
        return a
 }
 
-// TCPConn is an implementation of the Conn interface
-// for TCP network connections.
+// TCPConn is an implementation of the Conn interface for TCP network
+// connections.
 type TCPConn struct {
        conn
 }
@@ -96,17 +94,17 @@ func (c *TCPConn) CloseWrite() error {
        return c.fd.CloseWrite()
 }
 
-// SetLinger sets the behavior of Close() on a connection
-// which still has data waiting to be sent or to be acknowledged.
+// SetLinger sets the behavior of Close() on a connection which still
+// has data waiting to be sent or to be acknowledged.
 //
-// If sec < 0 (the default), Close returns immediately and
-// the operating system finishes sending the data in the background.
+// If sec < 0 (the default), Close returns immediately and the
+// operating system finishes sending the data in the background.
 //
 // If sec == 0, Close returns immediately and the operating system
 // discards any unsent or unacknowledged data.
 //
-// If sec > 0, Close blocks for at most sec seconds waiting for
-// data to be sent and acknowledged.
+// If sec > 0, Close blocks for at most sec seconds waiting for data
+// to be sent and acknowledged.
 func (c *TCPConn) SetLinger(sec int) error {
        if !c.ok() {
                return syscall.EINVAL
@@ -124,9 +122,9 @@ func (c *TCPConn) SetKeepAlive(keepalive bool) error {
 }
 
 // SetNoDelay controls whether the operating system should delay
-// packet transmission in hopes of sending fewer packets
-// (Nagle's algorithm).  The default is true (no delay), meaning
-// that data is sent as soon as possible after a Write.
+// packet transmission in hopes of sending fewer packets (Nagle's
+// algorithm).  The default is true (no delay), meaning that data is
+// sent as soon as possible after a Write.
 func (c *TCPConn) SetNoDelay(noDelay bool) error {
        if !c.ok() {
                return syscall.EINVAL
@@ -135,8 +133,8 @@ func (c *TCPConn) SetNoDelay(noDelay bool) error {
 }
 
 // DialTCP connects to the remote address raddr on the network net,
-// which must be "tcp", "tcp4", or "tcp6".  If laddr is not nil, it is used
-// as the local address for the connection.
+// which must be "tcp", "tcp4", or "tcp6".  If laddr is not nil, it is
+// used as the local address for the connection.
 func DialTCP(net string, laddr, raddr *TCPAddr) (*TCPConn, error) {
        switch net {
        case "tcp", "tcp4", "tcp6":
@@ -216,16 +214,15 @@ func spuriousENOTAVAIL(err error) bool {
        return ok && e.Err == syscall.EADDRNOTAVAIL
 }
 
-// TCPListener is a TCP network listener.
-// Clients should typically use variables of type Listener
-// instead of assuming TCP.
+// TCPListener is a TCP network listener.  Clients should typically
+// use variables of type Listener instead of assuming TCP.
 type TCPListener struct {
        fd *netFD
 }
 
-// AcceptTCP accepts the next incoming call and returns the new connection
-// and the remote address.
-func (l *TCPListener) AcceptTCP() (c *TCPConn, err error) {
+// AcceptTCP accepts the next incoming call and returns the new
+// connection and the remote address.
+func (l *TCPListener) AcceptTCP() (*TCPConn, error) {
        if l == nil || l.fd == nil {
                return nil, syscall.EINVAL
        }
@@ -236,14 +233,14 @@ func (l *TCPListener) AcceptTCP() (c *TCPConn, err error) {
        return newTCPConn(fd), nil
 }
 
-// Accept implements the Accept method in the Listener interface;
-// it waits for the next call and returns a generic Conn.
-func (l *TCPListener) Accept() (c Conn, err error) {
-       c1, err := l.AcceptTCP()
+// Accept implements the Accept method in the Listener interface; it
+// waits for the next call and returns a generic Conn.
+func (l *TCPListener) Accept() (Conn, error) {
+       c, err := l.AcceptTCP()
        if err != nil {
                return nil, err
        }
-       return c1, nil
+       return c, nil
 }
 
 // Close stops listening on the TCP address.
@@ -267,8 +264,8 @@ func (l *TCPListener) SetDeadline(t time.Time) error {
        return setDeadline(l.fd, t)
 }
 
-// File returns a copy of the underlying os.File, set to blocking mode.
-// It is the caller's responsibility to close f when finished.
+// File returns a copy of the underlying os.File, set to blocking
+// mode.  It is the caller's responsibility to close f when finished.
 // 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() }