forked from mirror/websocket
Improve Set{Read,Write}Deadline doc.
The new doc is inspired by the crypto/tls doc.
This commit is contained in:
parent
95caf726f7
commit
f4076986b6
17
conn.go
17
conn.go
|
@ -498,11 +498,10 @@ func (c *Conn) WriteMessage(messageType int, data []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWriteDeadline sets the deadline for future calls to NextWriter and the
|
// SetWriteDeadline sets the write deadline on the underlying network
|
||||||
// io.WriteCloser returned from NextWriter. If the deadline is reached, the
|
// connection. After a write has timed out, the websocket state is corrupt and
|
||||||
// call will fail with a timeout instead of blocking. A zero value for t means
|
// all future writes will return an error. A zero value for t means writes will
|
||||||
// Write will not time out. Even if Write times out, it may return n > 0,
|
// not time out
|
||||||
// indicating that some of the data was successfully written.
|
|
||||||
func (c *Conn) SetWriteDeadline(t time.Time) error {
|
func (c *Conn) SetWriteDeadline(t time.Time) error {
|
||||||
c.writeDeadline = t
|
c.writeDeadline = t
|
||||||
return nil
|
return nil
|
||||||
|
@ -734,10 +733,10 @@ func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
|
||||||
return messageType, p, err
|
return messageType, p, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetReadDeadline sets the deadline for future calls to NextReader and the
|
// SetReadDeadline sets the read deadline on the underlying network connection.
|
||||||
// io.Reader returned from NextReader. If the deadline is reached, the call
|
// After a read has timed out, the websocket connection state is corrupt and
|
||||||
// will fail with a timeout instead of blocking. A zero value for t means that
|
// all future reads will return an error. A zero value for t means reads will
|
||||||
// the methods will not time out.
|
// not time out.
|
||||||
func (c *Conn) SetReadDeadline(t time.Time) error {
|
func (c *Conn) SetReadDeadline(t time.Time) error {
|
||||||
return c.conn.SetReadDeadline(t)
|
return c.conn.SetReadDeadline(t)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue