@@ -116,12 +116,12 @@ type Addr interface {
116
116
// Multiple goroutines may invoke methods on a Conn simultaneously.
117
117
type Conn interface {
118
118
// Read reads data from the connection.
119
- // Read can be made to time out and return a Error with Timeout() == true
119
+ // Read can be made to time out and return an Error with Timeout() == true
120
120
// after a fixed time limit; see SetDeadline and SetReadDeadline.
121
121
Read (b []byte ) (n int , err error )
122
122
123
123
// Write writes data to the connection.
124
- // Write can be made to time out and return a Error with Timeout() == true
124
+ // Write can be made to time out and return an Error with Timeout() == true
125
125
// after a fixed time limit; see SetDeadline and SetWriteDeadline.
126
126
Write (b []byte ) (n int , err error )
127
127
@@ -143,7 +143,8 @@ type Conn interface {
143
143
// fail with a timeout (see type Error) instead of
144
144
// blocking. The deadline applies to all future and pending
145
145
// I/O, not just the immediately following call to Read or
146
- // Write.
146
+ // Write. After a deadline has been exceeded, the connection
147
+ // can be refreshed by setting a deadline in the future.
147
148
//
148
149
// An idle timeout can be implemented by repeatedly extending
149
150
// the deadline after successful Read or Write calls.
@@ -309,13 +310,13 @@ type PacketConn interface {
309
310
// bytes copied into b and the return address that
310
311
// was on the packet.
311
312
// ReadFrom can be made to time out and return
312
- // an error with Timeout() == true after a fixed time limit;
313
+ // an Error with Timeout() == true after a fixed time limit;
313
314
// see SetDeadline and SetReadDeadline.
314
315
ReadFrom (b []byte ) (n int , addr Addr , err error )
315
316
316
317
// WriteTo writes a packet with payload b to addr.
317
318
// WriteTo can be made to time out and return
318
- // an error with Timeout() == true after a fixed time limit;
319
+ // an Error with Timeout() == true after a fixed time limit;
319
320
// see SetDeadline and SetWriteDeadline.
320
321
// On packet-oriented connections, write timeouts are rare.
321
322
WriteTo (b []byte , addr Addr ) (n int , err error )
@@ -328,21 +329,32 @@ type PacketConn interface {
328
329
LocalAddr () Addr
329
330
330
331
// SetDeadline sets the read and write deadlines associated
331
- // with the connection.
332
+ // with the connection. It is equivalent to calling both
333
+ // SetReadDeadline and SetWriteDeadline.
334
+ //
335
+ // A deadline is an absolute time after which I/O operations
336
+ // fail with a timeout (see type Error) instead of
337
+ // blocking. The deadline applies to all future and pending
338
+ // I/O, not just the immediately following call to ReadFrom or
339
+ // WriteTo. After a deadline has been exceeded, the connection
340
+ // can be refreshed by setting a deadline in the future.
341
+ //
342
+ // An idle timeout can be implemented by repeatedly extending
343
+ // the deadline after successful ReadFrom or WriteTo calls.
344
+ //
345
+ // A zero value for t means I/O operations will not time out.
332
346
SetDeadline (t time.Time ) error
333
347
334
- // SetReadDeadline sets the deadline for future Read calls.
335
- // If the deadline is reached, Read will fail with a timeout
336
- // (see type Error) instead of blocking.
337
- // A zero value for t means Read will not time out.
348
+ // SetReadDeadline sets the deadline for future ReadFrom calls
349
+ // and any currently-blocked ReadFrom call.
350
+ // A zero value for t means ReadFrom will not time out.
338
351
SetReadDeadline (t time.Time ) error
339
352
340
- // SetWriteDeadline sets the deadline for future Write calls.
341
- // If the deadline is reached, Write will fail with a timeout
342
- // (see type Error) instead of blocking.
343
- // A zero value for t means Write will not time out.
353
+ // SetWriteDeadline sets the deadline for future WriteTo calls
354
+ // and any currently-blocked WriteTo call.
344
355
// Even if write times out, it may return n > 0, indicating that
345
356
// some of the data was successfully written.
357
+ // A zero value for t means WriteTo will not time out.
346
358
SetWriteDeadline (t time.Time ) error
347
359
}
348
360
0 commit comments