title: How to use socket in Python as a context manager?
body: <p>It seems like it would be only natural to do something like:</p>
  
  <pre><code>with socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
  </code></pre>
  
  <p>but Python doesn't implement a context manager for socket. Can I easily use it as a context manager, and if so, how?</p>