title: How does a WebSocket key work?
body: <p>Recently I have been researching WebSockets, I think they are very cool. However, if I take a look <a href="https://en.wikipedia.org/wiki/WebSocket#Protocol_handshake" rel="noreferrer">here</a>, some things are unclear for me.</p>
  
  <p>Request:</p>
  
  <pre><code>GET /chat HTTP/1.1
  Host: server.example.com
  Upgrade: websocket
  Connection: Upgrade
  Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
  Sec-WebSocket-Protocol: chat, superchat
  Sec-WebSocket-Version: 13
  Origin: http://example.com
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>HTTP/1.1 101 Switching Protocols
  Upgrade: websocket
  Connection: Upgrade
  Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
  Sec-WebSocket-Protocol: chat
  </code></pre>
  
  <p>The requester specifies the host, so intermediate servers will know where the request should arrive. The requester sends a random string encoded into base64 and the server sends back a salted SHA1-encrypted key back. Will this key be used between the two while the connection is alive? If so, is there a way this key can be reused even if the connection was broken?</p>