I think the issue is wrt to clearing the error queue. Whenever
you attempt to get the error number, we need to call  ERR_clear_error()
to clear it. Certain openssl API's call it internally, and some do not,
now am not clear as to why or on what basis. So, before calling SSL_read,
ensure you call the above mentioned function..this worked for me..I think
it doesnt matter if the underlying fd is b/nb..
 
--Gayathri
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Haridharan Nattamai
Sent: Thursday, April 20, 2006 10:05 AM
To: openssl-users@openssl.org
Subject: Re: errno=5 in SSL_read( )

Gayathri,

Thanks for your message.
I could see from your snippet you have used BIO in non blocking mode. But my application must be in such a way that it must wait to read the data. Do you have any idea on trying this for blocking mode.

thanks,
Haridharan


On 4/20/06, Gayathri Sundar <[EMAIL PROTECTED]> wrote:
I too faced similar problem when I pumped heavy data via smart bits..
this piece of code worked for me..btw the underlying bio in non blocking..
 
 
 do
  {
    ERR_clear_error();
    nbytesread = SSL_read(pSSLObject,pBuffer,BufSize);
    if(nbytesread > 0 )
    {
       totalbytesread += nbytesread;
       pBuffer = pBuffer + nbytesread;
       BufSize -= nbytesread;
    }
    if(errno == EAGAIN || errno == EINTR || errno == ENOMEM)
    {
      return (SSL_ERROR_NONE);
    }
    else if(!nbytesread)
    {
      return (-1 * SSL_ERROR_ZERO_RETURN);
    }
    else
    {
      err = SSL_get_error(pSSLObject,nbytesread);
      break;
    }
  }while(SSL_pending(pSSLObject) && (BufSize > 0));
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]]On Behalf Of Haridharan Nattamai
Sent: Wednesday, April 19, 2006 6:59 PM
To: openssl-users@openssl.org
Subject: errno=5 in SSL_read( )

Hi,

I'm using openssl v0.9.7i. When I try to receive a huge amount of data sometimes I get errno=5(SSL_ERROR_SYSCALL) and the exact response code is "EOF was observed that violates the protocol". At some cases when this error occurs, I get TCP ZeroWindowViolation in ethereal's trace log. I like to know what could be the reason and how can I override this.

Thanks in advance.

Haridharan

Reply via email to