@@ -111,13 +111,13 @@ type Addr interface {
111
111
// Multiple goroutines may invoke methods on a Conn simultaneously.
112
112
type Conn interface {
113
113
// Read reads data from the connection.
114
- // Read can be made to time out and return an Error with Timeout() == true
115
- // after a fixed time limit; see SetDeadline and SetReadDeadline.
114
+ // Read can be made to time out and return an error after a fixed
115
+ // time limit; see SetDeadline and SetReadDeadline.
116
116
Read (b []byte ) (n int , err error )
117
117
118
118
// Write writes data to the connection.
119
- // Write can be made to time out and return an Error with Timeout() == true
120
- // after a fixed time limit; see SetDeadline and SetWriteDeadline.
119
+ // Write can be made to time out and return an error after a fixed
120
+ // time limit; see SetDeadline and SetWriteDeadline.
121
121
Write (b []byte ) (n int , err error )
122
122
123
123
// Close closes the connection.
@@ -313,15 +313,13 @@ type PacketConn interface {
313
313
// It returns the number of bytes read (0 <= n <= len(p))
314
314
// and any error encountered. Callers should always process
315
315
// the n > 0 bytes returned before considering the error err.
316
- // ReadFrom can be made to time out and return
317
- // an Error with Timeout() == true after a fixed time limit;
318
- // see SetDeadline and SetReadDeadline.
316
+ // ReadFrom can be made to time out and return an error after a
317
+ // fixed time limit; see SetDeadline and SetReadDeadline.
319
318
ReadFrom (p []byte ) (n int , addr Addr , err error )
320
319
321
320
// WriteTo writes a packet with payload p to addr.
322
- // WriteTo can be made to time out and return
323
- // an Error with Timeout() == true after a fixed time limit;
324
- // see SetDeadline and SetWriteDeadline.
321
+ // WriteTo can be made to time out and return an Error after a
322
+ // fixed time limit; see SetDeadline and SetWriteDeadline.
325
323
// On packet-oriented connections, write timeouts are rare.
326
324
WriteTo (p []byte , addr Addr ) (n int , err error )
327
325
@@ -337,11 +335,17 @@ type PacketConn interface {
337
335
// SetReadDeadline and SetWriteDeadline.
338
336
//
339
337
// A deadline is an absolute time after which I/O operations
340
- // fail with a timeout (see type Error) instead of
341
- // blocking. The deadline applies to all future and pending
342
- // I/O, not just the immediately following call to ReadFrom or
343
- // WriteTo. After a deadline has been exceeded, the connection
344
- // can be refreshed by setting a deadline in the future.
338
+ // fail instead of blocking. The deadline applies to all future
339
+ // and pending I/O, not just the immediately following call to
340
+ // Read or Write. After a deadline has been exceeded, the
341
+ // connection can be refreshed by setting a deadline in the future.
342
+ //
343
+ // If the deadline is exceeded a call to Read or Write or to other
344
+ // I/O methods will return an error that wraps os.ErrDeadlineExceeded.
345
+ // This can be tested using errors.Is(err, os.ErrDeadlineExceeded).
346
+ // The error's Timeout method will return true, but note that there
347
+ // are other possible errors for which the Timeout method will
348
+ // return true even if the deadline has not been exceeded.
345
349
//
346
350
// An idle timeout can be implemented by repeatedly extending
347
351
// the deadline after successful ReadFrom or WriteTo calls.
0 commit comments