Handling network disconnects during read

View: New views
2 Messages — Rating Filter:   Alert me  

Handling network disconnects during read

by Michael Welsh Duggan-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
suggestions?

--
Michael Welsh Duggan
(mwd@...)


_______________________________________________
Help-gnutls mailing list
Help-gnutls@...
http://lists.gnu.org/mailman/listinfo/help-gnutls

Re: Handling network disconnects during read

by Nikos Mavrogiannopoulos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael Welsh Duggan wrote:

> 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.

Hello,
 Unfortunately this problem cannot be solved unless you use non blocking
sockets. The usage of select() with gnutls functions has this
side-effect since select only tells if there are data in the socket, not
if they are enough for a gnutls read.

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

If you want to stick on blocking sockets this is the "correct" solution.

regards,
Nikos




_______________________________________________
Help-gnutls mailing list
Help-gnutls@...
http://lists.gnu.org/mailman/listinfo/help-gnutls