[ANN] x0 HTTP server and framework (initial release)

Marc Lehmann schmorp at schmorp.de
Thu Apr 1 14:07:59 CEST 2010


On Thu, Apr 01, 2010 at 10:53:39AM +0200, Graham Leggett <minfrin at sharp.fm> wrote:
> You might be tempted to keep two socket watchers going for listening to 
> socket read events, and socket write events, but to support SSL  

This is the mess how it is commonly implemented, and it is indeed horrors.

A much easier way is to decouple openssl from the socket altogether,
i.e. don't let it do socket I/O, instead let it do I/O from/two two
BIO buffers, which simplifies things a lot - no need to watch for
SSL_WANT_READ and other issues, no need to switch watcher state based on
return codes etc.

Basically, each time you have some data activity, feed any new send data
to SSL_write (if there is some, just as if it were a nonblocking socket
itself), followed by trying to SSL_read any data.

When you have dtaa in the output buffer, you know thta you need to write
this, and if you receive data from the net, just feed it into the input
buffer and do the read thing.

Both SSL_read and _write use the same underlying state machine, just the
interface is a bit weird.

I wanted to make a C example for quite some time, but didn't get to it
yet.

Not that I wouldn't recomend gnutls over openssl based on the license
alone...

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list