[Ecls-list] Does ECL support SERVE-EVENT?

Brad Beveridge brad.beveridge at gmail.com
Wed Sep 6 23:08:53 UTC 2006


On 06/09/06, Dave Roberts <dave at vyatta.com> wrote:
> Brad Beveridge wrote:
> > I am writing a console application that uses ncurses, and will need to
> > respond to sockets.  My target Lisp implementations are primarily ECL
> > and SBCL.
> > SBCL has a neat function called SERVE-EVENT, you register various file
> > descriptors (in my case, each socket and standard input), and
> > associate callbacks with them.  When the user hits a key, my key
> > handler will get called, and when data comes in on a socket that
> > callback will get called, and my main loop basically boils down to
> > just calling SERVE-EVENT a lot.
> > At least, that's what I think will happen - I'm not actually at that
> > stage just yet.
> > Anyhow - is there something similar in ECL?  If there isn't I will
> > probably use CFFI to wrap the Posix select call, and do my own version
> > of SERVE-EVENT.
>
> Brad,
>
> I don't believe ECL has anything similar. If you do this, please sent a
> note to the list and let us know. I have a similar project and I'm going
> to have to do the same thing. Likewise, if I get there first, I'll let
> you know.
>
> -- Dave
I'll prototype this out in SBCL first to see if that handling system
does what I want.  I've just been reading a little bit about Posix
select - it looks to me as if some critical aspects of select are
platform specific - ie fd_set, and the macros
 FD_SET(fd, &fdset);
 FD_CLR(fd, &fdset);
 FD_ISSET(fd, &fdset);
 FD_COPY(&fdset_orig, &fdset_copy);
 FD_ZERO(&fdset);
This feels like a bit of a problem to me, as how can CFFI access these
macros and types port ably?  It looks to me as if the most portable
way to do this is to write a small amount of C that provides a few
functions
 void add_fd(int fd)
 void remove_fd (int fd)
 int fd_needs_attention (int fd)
 int my_select (...)

Then the Lisp code would need to call my_select, and test each fd to
see if it requires action.
How does this sound?

Cheers
Brad




More information about the ecl-devel mailing list