[iolib-devel] socket-of?

Stelian Ionescu stelian.ionescu-zeus at poste.it
Tue Jan 27 22:27:03 UTC 2009


On Tue, 2009-01-27 at 16:45 -0500, Matthew Mondor wrote:
> I've been trying to use the multiplexer and am ambiguous as to two
> things:
> 
> event-base appears to be a class which the user must instanciate.  I
> assume that this is to allow extending the class to allow using user
> data like kqueue does via the udata to have those passed around to event
> handlers?

No, it's to allow using more event queues in multiple threads. On a SMP
machine, you could have two separate threads managing ports 80 and
443(https) each one with its own event loop.

>   If so, it's interesting that the event handler functions do
> not get this object passed along, and that a custom lambda function
> should pass it to another level of custom handler functions.

All you get is that you give the event loop a closure to be invoked when
a certain event - a tuple (fd,type) - is received. If you want to have
private data per handler, close the handler around it: that's what
closures are for.

> The event handler functions are provided an fd rather than a socket.
> Is there an easy provided way to obtain the associated socket from an
> fd, or must a custom index or hash table be used for this?

You need to make a custom map from FDs to sockets.

The event loop is a very low-level mechanism which is quite flexible
precisely because of that: you can build more sophisticated and more
specific mechanisms on top of it. Some use it as a normal event loop,
others have built green threads with it. The choice is yours.

-- 
Stelian Ionescu a.k.a. fe[nl]ix
Quidquid latine dictum sit, altum videtur.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/iolib-devel/attachments/20090127/5b6f6935/attachment.sig>


More information about the iolib-devel mailing list