[Help-gnutls] gnutls and non blocking socket
Martin Lambers
marlam at web.de
Sat Jul 16 14:53:55 CEST 2005
On Wed, 13. Jul 2005, 18:17:58 +0200, Nikos Mavrogiannopoulos wrote:
> >Ok, I give some explanation of my problem :
> >Under windows (as it is not implemented under Linux) I've created a
> >socket with a RECV timeout.
> >I do a gnutls_record_recv on a TLS session built over the socket.
> >When the timeout expires, I try to send a packet with gnutls_record_send
> >on that TLS session. The point is that at this moment gnutls_record_send
> >always fail sending a -10 error (TLS session not correct).
>
> >I may have look in the bad place in the code but it seems that there's a
> >problem anyway.
>
> I don't think there is. Most probably you are using SO_RCVTIMEO to
> setsockopt, so you get something different as errno than EAGAIN or
> EINTR. This is like a BSD extension and I don't know if this can be
> handled by gnutls in a portable way. As a quick hack you could make
> a wrapper over recv() and return EINTR or EAGAIN when you get the
> timeout errno code.
As far as I know, EAGAIN is the errno return code of recv() when a
SO_RCVTIMEO timeout expires (and similar for SO_SNDTIMEO and send()),
and gnutls_record_recv() and gnutls_record_send() pass this through by
returning GNUTLS_E_AGAIN.
According to the Windows setsockopt() documentation at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
winsock/winsock/setsockopt_2.asp
there are two problems with using SO_*TIMEO on Windows:
1. They don't work correctly on systems older than Windows 2000.
2. The socket is unusable once a timeout occurs. (Which means they don't
work correctly even on Windows 2000 and newer).
This is probably the cause of the "TLS session not correct" error.
Martin
More information about the Gnutls-help
mailing list