Subject: Re: Newbie question - talking with lisp
From: (Rob Warnock)
Date: Fri, 04 Nov 2005 05:40:21 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Ryan White <> wrote:
| I'm playing with CMUCL and was wondering how to communicate with a
| running lisp session from the command line prompt (linux)
| I'd like to separate the  action of getting the lisp session up and
| running from the actual calls to functions etc, since starting the
| session and loading all my functions could, eventually be very expensive...

It sounds like what you want to do is fire up a copy of CMUCL at login
time [or even at system boot time] as a persistent server, and then
have a small client program that talks to the "CMUCL server", passing it
requests and getting responses back. This is easily done with CMUCL
[and most other Common Lisps too, by the way], which contains support
or listening to sockets. To simplify things and avoid most security
issues[1], you'll probably want to use local-domain (a.k.a Unix-domain)
sockets, and hide the socket inside a directory[2] to which only you
(that is, processes running under your user ID) have access. In the
CMUCL case, the following functions will be useful:

    MP:PROCESS-WAIT-UNTIL-FD-USABLE   [iff making your server multithreaded]

Little-known fact: Recent versions of the standard "telnet" program
can connect to such sockets by specifying an absolute local pathname
instead of a hostname or IP address. So you should be able to test
your server this way:

    $ echo '(expt 2 100)' | telnet $HOME/tmp/demo.sock
    Trying /u/rpw3/tmp/demo.sock...
    Escape character is '^]'.
    Connection closed by foreign host.


[1] You can certainly use TCP sockets, but then any system anywhere
    might acess your Lisp process, so you'll need some kind of
    authentication. Doing authentication securely can be very tricky.
    Cleartext passwords can be snooped on the wire [and are clumsy
    for you to use in your client program], but for an example of how
    one might do it anyway, see the source for the CMUCL function

[2] On some Unix-like operating system the permissions on a local-domain
    socket special file are honored, but on others they are not -- any
    process that can stat the socket can open it. For this reason, it's
    safest to always place such socket special files under a directory
    which permits access only to the desired user-ID or group-ID.

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607