title: Check whether socket is closed in bash?
body: <p>I've got a file descriptor that points to a socket (example code below).</p>
  
  <pre><code>exec 3&lt;&gt;/dev/tcp/localhost/9999
  echo -e "Some Command\n" &gt;&amp;3
  </code></pre>
  
  <p>Sometimes that socket closes and needs to be re-opened (a restart of the server).</p>
  
  <p>How can I test if the socket (fd #3 in this case) is writable?</p>
  
  <p>The echo will always succeed, regardless of whether the socket has been closed already or not.</p>