Lisp HUG Maillist Archive

Multiplexing/select()-like blocking in LispWorks

Is there any select()-like operator available to wait on an event from
one of several sockets? Per Dave Robert's paper "Common Lisp Socket
APIs"¹, it looks like LispWorks requires one to use multiple threads
to block on multiple sockets, perhaps in concert with the
comm:with-noticed-socket-stream macro (which is apparently not
implemented, or perhaps just not necessary, on Windows).

I couldn't find anything in the documentation that sounded
appropriate, so I'm asking here just to make sure.

Follow on question: Will the answer change in LispWorks 5?


Footnotes: 
¹ http://www.findinglisp.com/papers/sockets-analysis-0-2-5.pdf

-- 
Steven E. Harris


Re: Multiplexing/select()-like blocking in LispWorks


"Steven E. Harris" <steven.harris@gnostech.com> writes:
> Is there any select()-like operator available to wait on an event from

I don't believe there is.  

What LispWorks does have is a polling interface that you can use to
similar effect.  For example, the Araneida web server has this
function in LispWorks:

  (defun socket-input-available (socket)
    (comm::socket-listen socket))

STREAM-LISTEN is an exported function that does a similar thing.

There are also some non-blocking IO functions such as
STREAM-READ-CHAR-NO-HANG.

Also, there is an NIO library being built that uses epoll and kqueue
on Linux.  http://common-lisp.net/project/nio/ (I have no experience
with NIO.)

> it looks like LispWorks requires one to use multiple threads to
> block on multiple sockets

That works well enough for systems that don't need to be very highly
scalable.  Works for me!  (At least for many of my smaller services.)
As you probably know, once you have hundreds of threads this does
start to break down.

Cheers,
Chris Dean


Updated at: 2020-12-10 08:48 UTC