net: deduplicate TCP socket code

This change consolidates functions and methods related to TCPAddr,
TCPConn and TCPListener for maintenance purpose, especially for
documentation. Also refactors Dial error code paths.

The followup changes will update comments and examples.

Updates #10624.

Change-Id: I3333ee218ebcd08928f9e2826cd1984d15ea153e
Reviewed-on: https://go-review.googlesource.com/20009
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Mikio Hara 2016-03-02 20:08:18 +09:00
parent 533f30b924
commit b0f4ee533a
13 changed files with 326 additions and 405 deletions

View file

@ -91,6 +91,9 @@ second:
case *os.SyscallError:
nestedErr = err.Err
goto third
case *os.PathError: // for Plan 9
nestedErr = err.Err
goto third
}
switch nestedErr {
case errCanceled, errClosing, errMissingAddress:
@ -543,6 +546,9 @@ second:
case *os.SyscallError:
nestedErr = err.Err
goto third
case *os.PathError: // for Plan 9
nestedErr = err.Err
goto third
}
switch nestedErr {
case errClosing, errTimeout: