Do something like this for a SSL_read() and something very similar for
SSL_write() and SSL_shutdown(), etc. (I'm assuming non-blocking sockets):
-----------------------------------------------------------------------------------------------------------------
totalbytesread=0;
stop='n';
unsigned char buf[bufsize]="\0";
totaltime=0;
memset(buf, 0, bufsize);
do {
ret=select(maxfd + 1, &readfds, &writefds, &exceptionfds, timeout);
if(select() fails, times out, or has exceptionfds) {
bail='y';
}
if((stop=='n')&&(bail=='n')) {
if(bufsize-1-totalbytesread < 1) {
stop='y'; and/or bail='y'; depending on your situation; }
if((stop=='n')&&(bail=='n')) {
ret2=SSL_Read(&buf[totalbytesread], bufsize-1-totalbytesread);
if(ret2<1) {
ret3=SSL_get_error(ret2);
if((ret3!=WANT_READ)&&(ret3!=WANT_WRITE)) {
bail='y';
} if((ret3!=WANT_READ)&&(ret3!=WANT_WRITE))
} //if(ret2<1)
else { //OK, we've read more bytes
oldtotalbytesread=totalbytesread;
totalbytesread=ret2+totalbytesread;
if((bufsize-1-totalbytesread)<1) {
buf[oldtotalbytesread]='\0';
stop='y'; and/or bail='y'; depending on your situation;
} else {
buf[totalbytesread]='\0';
}
if((bail=='n')&&(stop=='n')) {
totaltime=totaltime+(this time here - last time here);
Check to see if buf contains information that "tells" you it's time to stop or
if too much time has been taken for this whole SSL_Read() routine.
if(time to stop) {
stop='y'; (and/or bail='y' for too much time) ; depending on your situation.
} //if(time to stop)
} //if((bail=='n')&&(stop=='n'))
} //else OK, we've read more bytes
} //if((stop=='n')&&(bail=='n'))
} //if((stop=='n')&&(bail=='n'))
} //while((stop=='n')&&(bail=='n'));
if(bail=='n'){
printf("\nbuf=(%s).\0", buf);
} else {
printf("\nFatal Error!\0");
}
-----------------------------------------------------------------------------------------------------------------
Good luck!
Joe
Steven Young wrote:
Apologies if this is a duplicate; I was messing around with my e-mail
yesterday and it was broken for a while. I didn't see this go through.
On Sun, Aug 20, 2006 at 06:54:36PM -0400, Joe Flowers wrote:
It means call exactly the same SSL function you just did with the exact
same parameters as you just did that produced this SSL_ERROR_WANT_WRITE
return.
Pardon me, I think I'm a little thick today. I get what you're
all saying but I'm still not 100% sure of how this should be applied.
Here's the program flow, without SSL:
while(!quit) {
for(i in all file descriptors) {
if(we have something buffered up to say to the server)
FD_SET(thisfd, &writefds)
/* we are always interested in what the server has to say
* to us */
FD_SET(thisfd, &readfds);
}
select(maxfd + 1, &readfds, &writefds, NULL, timeout);
if(FD_ISSET(thisfd, &readfds)) {
read(thisfd), process it, probably send a reply with write()
} else if(FD_ISSET(thisfd, &writefds) {
write(thisfd) whatever we have buffered up; if it was a partial
write, update the buffer.
}
}
Using SSL, how should this look? From what I'm hearing, it shouldn't
use select() at all. So how do I find out if the server has something
to say short of polling it with SSL_read?
Thanks,
Steve.
----- End forwarded message -----
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager [EMAIL PROTECTED]