[gnutls-devel] Question regarding gnutls_record_set_timeout()

Tim Ruehsen tim.ruehsen at gmx.de
Thu Sep 17 16:52:32 CEST 2015


On Thursday 17 September 2015 14:53:06 Nikos Mavrogiannopoulos wrote:
> On Wed, Sep 16, 2015 at 4:57 PM, Tim Ruehsen <tim.ruehsen at gmx.de> wrote:
> > Hi,
> > I would like to use gnutls_record_set_timeout() instead of using my own
> > timeout code.
> > I see no way to specify an 'indefinite' timeout, e.g. by using a negative
> > value. Should I set the fd to blocking or what is the best 'gnutls' way ?
> 
> The timeout for this function only makes sense with blocking fds. For
> non-blocking fds you always have the function return as soon as
> possible. By not setting a timeout with this function you get the
> indefinite timeout. Does this answer your question?

Just a slight correction.
I use gnutls_record_set_timeout() / gnutls_record_recv() together with non-
blocking sockets. And it works flawlessly since the timeout just adds a 
select() before the read().
If you take a blocking fd, you might experience a select() saying 'yo man, 
it's readable' and the subsequent read() being stuck. At least I experienced 
this a long time ago and since than I never used blocking fds any more :-)
(but this is beyond discussion here, I guess).

So, Yes. So far I can live with a max. timeout of 2^32 / 1000 seconds (that's 
almost 50 days). I guess no one ever complains...

Thanks for your answer and sorry for the noise.

Tim




More information about the Gnutls-devel mailing list