handle all cases for SSL_write