title: How to use ws.SetWriteDeadline?
body: <p>When I close a browser I want to disconnect a websocket in 3 seconds instead of 1 minute. The following just keep writing into a void without error until the tcp ip timeout I guess, not the SetWriteDeadline.</p>
  
  <pre><code>f := func(ws *websocket.Conn) {
      for {
          select {
          case msg := &lt;-out:
              ws.SetWriteDeadline(time.Now().Add(3 * time.Second))
              if _, err := ws.Write([]byte(msg)); err != nil {
                  fmt.Println(err)
                  return
              }
          case &lt;-time.After(3 * time.Second):
              fmt.Println("timeout 3")
              return
          }
      }
  }
  return websocket.Handler(f)
  </code></pre>
  
  <p>I need to wait for this err</p>
  
  <p><code>write tcp [::1]:8080-&gt;[::1]:65459: write: broken pipe</code></p>
  
  <p>before it finally closes the connection, which takes about a minute or more.</p>