title: Do I need to handle SSL_ERROR_WANT_WRITE when SSL_read()?
body: <p>I'm reading an openssl programming <a href="http://www.rtfm.com/openssl-examples/part2.pdf" rel="nofollow">tutorial</a>.</p>
  
  <p>I can't let a server app to be blocked on any operation for a single connection,<br>
  hence I'll use non-block sockets.  </p>
  
  <p>Since it seems, ssl handshaking takes place at ssl_accept and ssl_connect,<br>
  and this could be blocked, I'll have to set socket to non-block before the ssl_accept call.  </p>
  
  <p>The tutorial doc says I need to handle SSL_ERROR_WANT_WRITE(plus SSL_ERROR_WANT_READ of course) on SSL_read because SSL rehandshaking could take place anytime.<br>
  And SSL_ERROR_WANT_READ on SSL_write for the same reason.  </p>
  
  <p>From the doc,</p>
  
  <blockquote>
    <p>We get a WANT_WRITE if we’re  trying
    to rehandshake and we block on  a
    write during that rehandshake.</p>
    
    <p>We need to wait on the socket to be 
    writeable but reinitiate the read 
    when it is</p>
  </blockquote>
  
  <p>I'm confused on the part of "re"handshaking.<br>
  I'm not planning to save ssl state and reuse it (this is called session resumption?)
  After the first handshaking I won't have to deal with handshaking for the same connection.  </p>
  
  <p><strong>I wonder if I still need to worry about WANT_WRITE on SSL_read and vice versa when I am not gonna use session resumption.</strong>  </p>
  
  <p>Thank you</p>