help-gnutls
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gnutls] Equivalent to fdopen?


From: Brian Lavender
Subject: Re: [Help-gnutls] Equivalent to fdopen?
Date: Wed, 13 Aug 2008 11:30:56 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

On Sat, Aug 09, 2008 at 12:39:52PM +0300, Nikos Mavrogiannopoulos wrote:
> 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.

Ok, thanks. I thought maybe I was overlooking something. I ended up
creating a buffer, reading into it, and then looking for a newline in it.

brian
-- 
Brian Lavender
http://www.brie.com/brian/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]