Hi,

        Once again I try to explain my problem. I am having a client sending
"unknown size of data" to server. Server doesn't know how much to
receive, but the length of the data is embedded inside the data itself (
initial 32 bytes contains this info ). So server has to read the initial
bytes of data, determine the length of complete payload and then read
the complete data. So the question is how do I do it ? For implementing
this I need a recursive call to ssl_read which I am not able to ..  The
code snippet I attached was trying to read 32 bytes recursively and
print it on console. It indeed reads 32 bytes but only once and wait
infinitely after that ..

Is this something someone has tried before and has code samples
available for reference ?

On Sun, 2005-03-13 at 00:51, David Schwartz wrote:

David,

        There is a common break for SSL_ERROR_NONE and ERROR_ZERO_RETURN. Also
every time ssl_read is successful I am printing the data on console, so
there is no question of overwriting the data.

Regards,

/Mahesh


> 
> >         I am trying to use ssl_read in the loop for receiving the data
> > of
> > unknown size ( say 988 bytes for now ). But it fails to read after a
> > single pass. Everytime it exits with ret = 32 and error=SSL_ERROR_NONE.
> > Am I missing something here .. Please find attached the code snippet. Is
> > there any example code available ?
> 
>       Your code is broken in several ways. For one thing, when is the loop
> supposed to return, assuming there is no error?
> 
> >         char buf[1024];Regards,

/Mahesh

> >         bool loop=TRUE;
> >         if( !waitRead(error) )
> >                 return -1;
> >         else
> >         {
> >             do
> >             {
> >                 ret=SSL_read(ssl, buf, 32);
> >
> >                 printf("The data in ssl read is %s\n", buf);
> >                 int err = SSL_get_error(ssl, ret);
> >
> >                 switch(err)Regards,

/Mahesh

> >                 {SSL_ERROR_NONE
> >                      case SSL_ERROR_NONE: /* this is not an error */
> 
>       Shouldn't there be a 'break' here?ERROR_ZERO_RETURN
> 
> >                      case SSL_ERROR_ZERO_RETURN: /* no more data */
> >                                 loop=FALSE; /* get out of loop */
> >                                 printf("No more data \n");
> >                                 break;
> >                      case SSL_ERROR_WANT_READ:
> >                      case SSL_ERROR_WANT_WRITE:
> >                                 printf("Pending data \n");
> >                                 break;
> >                 }
> >                 }
> >
> >             }while(loop);
> >         }
> 
>       The code you posted, even with the missing 'break' appears to continue
> reading the data on an SSL connection, overwriting each 32 bytes with the
> next 32 bytes, until the other side closes the connection or an error
> occurs. It's hard to imagine how that's useful.
> 
>       DS
> 
> 
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> Development Mailing List                       openssl-dev@openssl.org
> Automated List Manager                           [EMAIL PROTECTED]


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to