title: If I want to call SSL_shutdown() with non-blocking sockets, do I need to keep calling SSL_read() first until it yields SSL_ERROR_WANT_READ?
body: <p>Given a scenario where:</p>
  
  <ul>
  <li>multiple SSL/TLS records have arrived on a single socket</li>
  <li>those records are parsed one at a time with <code>SSL_read()</code> (and a large enough buffer to hold them).</li>
  <li>prior to parsing the final record buffered at the SSL layer, I detect invalid application data and want to close the connection without parsing the remaining incoming data</li>
  </ul>
  
  <p>Will <code>SSL_shutdown()</code> discard any remaining SSL read data on the socket for which I haven't called <code>SSL_read()</code> read yet, or do I always need to just keep on calling <code>SSL_read()</code> first until it yields <code>SSL_ERROR_WANT_READ</code> (which would waste CPU cycles extracting data I don't even care about anymore) and then call <code>SSL_shutdown()</code>?</p>
  
  <p>What concerns me is that <code>SSL_shutdown()</code> too can yield <code>SSL_ERROR_WANT_READ</code> (according to the man page at least), but if for whatever reason there is still unread data on the socket, I won't necessarily be notified of new incoming packets because of how I use <code>epoll_wait()</code>.</p>