From: Matt Joiner Date: Sat, 21 Feb 2015 03:58:28 +0000 (+1100) Subject: Comments X-Git-Tag: v1.0.0~1329 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=e067bff5b3e6533ac97fe2edb790509a87f2afbf;p=btrtrc.git Comments --- diff --git a/client.go b/client.go index c5ad0dd1..ba689c91 100644 --- a/client.go +++ b/client.go @@ -830,6 +830,8 @@ func handshake(sock io.ReadWriteCloser, ih *InfoHash, peerID [20]byte) (res hand return } +// Wraps a raw connection and provides the interface we want for using the +// connection in the message loop. type peerConn struct { net.Conn } @@ -841,6 +843,7 @@ func (pc peerConn) Read(b []byte) (n int, err error) { err = fmt.Errorf("error setting read deadline: %s", err) } n, err = pc.Conn.Read(b) + // Convert common errors into io.EOF. if err != nil { if opError, ok := err.(*net.OpError); ok && opError.Op == "read" && opError.Err == syscall.ECONNRESET { err = io.EOF