Hi Lars,

Thanks very much for that intro. I will go through the source code of sw-http.

Chaitanya

Lars Rune Nøstdal wrote:
On Fri, 2008-12-19 at 03:04 +0530, Chaitanya Gupta wrote:
  
Hi,

I can't seem to find the IOLib documentation -- there's no link to it on 
the project page at common-lisp.net.

I want to try out the I/O multiplexer but I am clueless on how to go 
about working with it. Any help on this (or pointer to the doc location) 
would be great.

Cheers,
Chaitanya


    

Hi,
I've written a simple HTTP server that uses IOLib. Maybe it can help one
figure out how IOLib works or can be used:

  http://common-lisp.net/~lnostdal/programming/lisp/sw-http/


Basically start by creating a server socket (server.lisp):

  * make-socket (iolib)
  * ..and make it non-blocking
  * set-io-handler (iolib)
  * set-error-handler (iolib)


set-io-handler (iolib) dispatches to the handle-socket-event (sw-http,
server.lisp) callback which calls connection-start-reading (sw-http,
connection.lisp).

connection-start-reading sets up a new callback, connection-handle
(sw-http, connection.lisp) by calling set-io-handler (iolib) on the
client socket. It also makes sure the client socket is made
non-blocking.

connection-handle has a (case event ..) form which leads to
request-handle (sw-http, request-incoming.lisp) for :read events.

Ok, that's basically it with regards to the multiplexing stuff really.

This should be familiar stuff quite similar to what's going on in C on a
"concept" level. You keep reading until reading would block then make a
note of where you are now then return to the event loop (the blocking
event-dispatch call/loop in server.lisp) so the next waiting event in
line can be served.



_______________________________________________
IOLib-devel mailing list
IOLib-devel@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/iolib-devel