select + record_recv

lfinsto at lfinsto at
Wed Jul 14 12:20:31 CEST 2010

On Sat, July 10, 2010 11:44 pm, Nikos Mavrogiannopoulos wrote:
> In the early versions of GnuTLS I implemented a hack in order to use
> select() to check whether there are data to read from the gnutls
> session. Is this feature actually used? If you want to check for data in
> a gnutls_session how do you do it?

No, I don't use it, but I probably would have, if I'd known about it.  I
must have missed it in the documentation.

Instead, I've taken some trouble to ensure that the client and server are
"synchronized" in the sense that server always gets a message from the
client when it's waiting for one and vice versa.  In a couple of places,
it's necessary for one or the other to signal the peer to stop waiting. 
It does this by sending a single null byte.  In this case, the message is
not processed.  Otherwise, if there's data, it is passed to the respective
parser function.  The server's parser function has a rule for "Client
finished" and the client's parser function has a rule for "Server
finished".  Normally, the client will end the connection when it's
finished and the server has told the client that it's finished.  Handling
error conditions is somewhat more complicated, but the connection should
never just be broken off.

This approach seems to work well and I wouldn't change it for one that
uses polling at this point. With my application, connections shouldn't
normally be left open for a long time with wide gaps between messages from
one peer to the other.


> regards,
> Nikos
> _______________________________________________
> Gnutls-devel mailing list
> Gnutls-devel at

Laurence Finston
Gesellschaft fuer wissenschaftliche Datenverarbeitung mbH
Am Fassberg 11
37077 Goettingen

Telefon: 	+49 551 201-1882
E-Mail: 	lfinsto at

More information about the Gnutls-devel mailing list