[Help-gnutls] Equivalent to fdopen?

Nikos Mavrogiannopoulos nmav at gnutls.org
Sat Aug 9 11:39:52 CEST 2008


Brian Lavender wrote:
> I am trying to take a simple socket program and convert it to use
> gnutls. Is there an equivalent to fdopen so I can stream my secured
> socket as an fstream?
> 
> int sock_fd;
> FILE *sock_fpi;
> 
> sock_fd = accept( sock_id, (struct sockaddr *) &sa_cli, &client_len );
> 
> sock_fpi = fdopen( sock_fd, "r" ))
> 
> But when I attempt to convert it to use gnutls, I run into the
> following.
> 
> sock_fd = accept( sock_id, (struct sockaddr *) &sa_cli, &client_len );
> 
> session = initialize_tls_session ();
> 
> gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sock_fd );
> 
> ret = gnutls_handshake (session);
> 
> And, it appears that I can only read using the following command.
> 
> ret = gnutls_record_recv (session, buffer, MAX_BUF);

Isn't this the expected behavior? gnutls does not know about FILE*
pointers, only about descriptors. You'd need a wrapper over
gnutls_record_recv for that.

regards,
Nikos





More information about the Gnutls-help mailing list