
// Send the close_notify alert.
ret = SSL_shutdown(ssl);
switch (ret) {
case 1:
  // A close_notify alert has already been received.
  break;
case 0:
  // Wait for the close_notify alert from the peer.
  ret = SSL_shutdown(ssl);
  switch (ret) {
  case 0:
    fprintf(stderr, "info: second SSL_shutdown returned zero\n");
    break;
  case 1:
    break;
  default:
    ssl_print_error_and_exit(ssl, "SSL_shutdown 2", ret);
  }
  break;
default:
  ssl_print_error_and_exit(ssl, "SSL_shutdown 1", ret);
}
SSL_free(ssl);
close(sockfd);

