[Help-gnutls] GNU TLS inside a loop: what to do at each iteration?

Stephane Bortzmeyer bortzmeyer at nic.fr
Fri Nov 7 14:07:21 CET 2003


On Thu, Nov 06, 2003 at 12:39:39PM +0200,
 Nikos Mavroyanopoulos <nmav at gnutls.org> wrote 
 a message of 37 lines which said:

> The example in section 5.2.5 (client with resume capability)
> connects to a server twice by using a loop. 

OK, my fault, I had a gnutls_global_deinit at the wrong place in the
loop. I now have the following structure:

      gnutls_global_init ();
      gnutls_certificate_allocate_credentials (&xcred);
 
      loop {
          gnutls_init (&session, GNUTLS_CLIENT);
	  gnutls_set_default_priority (session);
	  gnutls_certificate_type_set_priority (session,
						    cert_type_priority);
	  gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);
	  gnutls_transport_set_ptr (session,
					(gnutls_transport_ptr) sockfd);
	  gnutls_handshake (session);
          Work ...
          shutdown()
	  gnutls_bye (channel.tls, GNUTLS_SHUT_RDWR);
	  gnutls_deinit (session);
      }

      gnutls_global_deinit ();

And it works fine. Many thanks.

Those who want to see it:

ftp://ftp.internatif.org/pub/unix/echoping/echoping-5.1-BETA.tar.gz





More information about the Gnutls-help mailing list