According to the doc: 0 indicates the ssl_shutdown function needs to be called again. 1 indicates success -1 indicates failure
if r = ssl_shutdown() == -1 // failure if r == 0 r = ssl_shutdown if r == < 1 // failure else //success Stuart ----- Original Message ---- From: Matthew Allen <l...@sydneyband.com.au> To: openssl-users@openssl.org Sent: Wed, April 21, 2010 4:00:10 PM Subject: Re: Socket left in CLOSE_WAIT state... ---------- Original Message ---------- To: (openssl-users@openssl.org) From: Stuart Weatherby (stuart_weathe...@yahoo.ca) Subject: Re: Socket left in CLOSE_WAIT state... Date: 22/4/2010 5:18:48a > Shutdown disables the ability to read, write (or both) on a > socket. However, shutdown() does not close the socket. to release the > socket descriptor back to the OS you also need to call closesocket(); This code does want I want: int r = 0; if ((r = SSL_shutdown(Ssl)) >= 0) { closesocket(SSL_get_fd(Ssl)); } But it seems like an ugly hack. It _should_ close the socket by itself. I'm worried that this leakes some BIO object(s), because clearly if the BIO objects were free'd they'd close their SOCKET. And since that ISN'T happening maybe the BIO object is not being free [correctly]. > Saju Paul wrote: > Looks like it needs a BIO_free_all(bio) or something similair. I tried that before and after the SSL_shutdown call and it just crashes, clearly thats not the "proper" way. Maybe there is a way to disassociate the BIO from the SSL but it seems like a hack rather than a solution. Thanks for the responses. PS in investigating these issues I did try and download + build OpenSSL 1.0.0 for myself, hoping to step into the code and see where things went, but after following the instructions to build with Visual C++ I got stuck running a command that never finished. The perl "do_ms" thing would run for hours using up 100% of the core it was running on and just never seem to finish. Ended up killing it and posting on the mailing list instead. Just FYI. -- Matthew Allen http://www.memecode.com ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org