Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/net/net.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The following is copied from Go 1.16 official implementation.
// The following is copied from Go 1.18 official implementation.

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down Expand Up @@ -39,10 +39,10 @@ type Conn interface {
// Any blocked Read or Write operations will be unblocked and return errors.
Close() error

// LocalAddr returns the local network address.
// LocalAddr returns the local network address, if known.
LocalAddr() Addr

// RemoteAddr returns the remote network address.
// RemoteAddr returns the remote network address, if known.
RemoteAddr() Addr

// SetDeadline sets the read and write deadlines associated
Expand Down Expand Up @@ -103,8 +103,12 @@ type Listener interface {
// An Error represents a network error.
type Error interface {
error
Timeout() bool // Is the error a timeout?
Temporary() bool // Is the error temporary?
Timeout() bool // Is the error a timeout?

// Deprecated: Temporary errors are not well-defined.
// Most "temporary" errors are timeouts, and the few exceptions are surprising.
// Do not use this method.
Temporary() bool
}

// OpError is the error type usually returned by functions in the net
Expand Down Expand Up @@ -220,6 +224,12 @@ var (
_ io.Reader = (*Buffers)(nil)
)

// WriteTo writes contents of the buffers to w.
//
// WriteTo implements io.WriterTo for Buffers.
//
// WriteTo modifies the slice v as well as v[i] for 0 <= i < len(v),
// but does not modify v[i][j] for any i, j.
func (v *Buffers) WriteTo(w io.Writer) (n int64, err error) {
if wv, ok := w.(buffersWriter); ok {
return wv.writeBuffers(v)
Expand All @@ -236,6 +246,12 @@ func (v *Buffers) WriteTo(w io.Writer) (n int64, err error) {
return n, nil
}

// Read from the buffers.
//
// Read implements io.Reader for Buffers.
//
// Read modifies the slice v as well as v[i] for 0 <= i < len(v),
// but does not modify v[i][j] for any i, j.
func (v *Buffers) Read(p []byte) (n int, err error) {
for len(p) > 0 && len(*v) > 0 {
n0 := copy(p, (*v)[0])
Expand Down