aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/net/net.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/net.go')
-rw-r--r--libgo/go/net/net.go24
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.