diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-07-22 18:15:38 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-07-22 18:15:38 +0000 |
commit | 22b955cca564a9a3a5b8c9d9dd1e295b7943c128 (patch) | |
tree | abdbd898676e1f853fca2d7e031d105d7ebcf676 /libgo/go/net/net.go | |
parent | 9d04a3af4c6491536badf6bde9707c907e4d196b (diff) | |
download | gcc-22b955cca564a9a3a5b8c9d9dd1e295b7943c128.zip gcc-22b955cca564a9a3a5b8c9d9dd1e295b7943c128.tar.gz gcc-22b955cca564a9a3a5b8c9d9dd1e295b7943c128.tar.bz2 |
libgo: update to go1.7rc3
Reviewed-on: https://go-review.googlesource.com/25150
From-SVN: r238662
Diffstat (limited to 'libgo/go/net/net.go')
-rw-r--r-- | libgo/go/net/net.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libgo/go/net/net.go b/libgo/go/net/net.go index d9d23fa..d6812d1 100644 --- a/libgo/go/net/net.go +++ b/libgo/go/net/net.go @@ -14,7 +14,7 @@ the same interfaces and similar Dial and Listen functions. The Dial function connects to a server: - conn, err := net.Dial("tcp", "google.com:80") + conn, err := net.Dial("tcp", "golang.org:80") if err != nil { // handle error } @@ -79,6 +79,7 @@ On Windows, the resolver always uses C library functions, such as GetAddrInfo an package net import ( + "context" "errors" "io" "os" @@ -297,7 +298,7 @@ func (c *conn) File() (f *os.File, err error) { // Multiple goroutines may invoke methods on a PacketConn simultaneously. type PacketConn interface { // ReadFrom reads a packet from the connection, - // copying the payload into b. It returns the number of + // copying the payload into b. It returns the number of // bytes copied into b and the return address that // was on the packet. // ReadFrom can be made to time out and return @@ -364,6 +365,9 @@ type Error interface { // Various errors contained in OpError. var ( + // For connection setup operations. + errNoSuitableAddress = errors.New("no suitable address found") + // For connection setup and write operations. errMissingAddress = errors.New("missing address") @@ -374,6 +378,22 @@ var ( ErrWriteToConnected = errors.New("use of WriteTo with pre-connected connection") ) +// mapErr maps from the context errors to the historical internal net +// error values. +// +// TODO(bradfitz): get rid of this after adjusting tests and making +// context.DeadlineExceeded implement net.Error? +func mapErr(err error) error { + switch err { + case context.Canceled: + return errCanceled + case context.DeadlineExceeded: + return errTimeout + default: + return err + } +} + // OpError is the error type usually returned by functions in the net // package. It describes the operation, network type, and address of // an error. |