Darryl, Thanks for your detailed suggestions, especially:
> It may also be helpful to call SSL_set_read_ahead(ssl, 0) to disable > readahead optimization just before you issue the SSL_shutdown(ssl). For some reason, adding that line before the shutdowns made all the difference - it now works perfectly. Thanks also to Viktor and David. cheers, Andrew