Handling network disconnects during read

Michael Welsh Duggan mwd at cert.org
Fri Oct 9 16:54:40 CEST 2009

I've been encountering a problem using gnutls_record_recv() using old
versions of gnutls, and I want to find out if a) current versions are
not subject to this problem, or b) there is a decent workaround to this
problem that I have not considered.  The version of gnutls that I am
currently constrained to work with is v1.4.1.

I am reading data using gnutls_record_recv().  I am using select() to
determine whether there is data available on that socket before calling
gnutls_record_recv().  Internally, gnutls_record_recv() appears to be
doing multiple recv calls until "enough" data is read.  If a network
disconnect happens in between recv calls in such a way that the os
cannot determine that the connection is disconnected, then the recv
call blocks.  This currently hangs my software.

I have a potential workaround I am looking at involving writing my own
pull function, but I am not particularly happy with it.  Any

Michael Welsh Duggan
(mwd at cert.org)

More information about the Gnutls-help mailing list