Hello,
I was wondering if anyone had some example code or knew of a good
web site
for introducing me to the delights of sending the output of a lisp
program
to a program written in C. I believe sockets are good but know nothing
about
them.
cheers
Dr Gary Petley
Gary Petley wrote:
> Hello,
>
On Unix you can make a fifo and write to the fifo from the Lisp program
and read from the fifo from the C program. The advantage is that the
fifo looks like another file to both C and Lisp. It might just be my
impression but socket code in Lisp seems to be very implementation
dependant.
>
> I was wondering if anyone had some example code or knew of a good
> web site
> for introducing me to the delights of sending the output of a lisp
> program
> to a program written in C. I believe sockets are good but know nothing
> about
> them.
>
> cheers
>
> Dr Gary Petley
"Paul C. Hoehne" <·······@penguinwerks.com> writes:
> On Unix you can make a fifo and write to the fifo from the Lisp program
> and read from the fifo from the C program. The advantage is that the
> fifo looks like another file to both C and Lisp. It might just be my
> impression but socket code in Lisp seems to be very implementation
> dependant.
While socket code generally is implementation-dependant, the stuff
needed to do simple blocking communication over sockets generally only
requires a modicum of implementation-dependant stuff: All reasonable
implementations of sockets in CL will offer you a way to get a stream
to the socket once a connection has been made. Reading from and
writing to the stream will use the normal ANSI CL stream operators, as
will closing the connection/stream combo. So the only part that will
really be implementation-dependend will be the code to set up the
socket stream on the sender/receiver sides in the first place. That
will only be a small amount of code in one place, so should pose no
serious portability problems.
While this is a bit more complicated than using a fifo, you will
generally get cross-machine communication for free/little effort with
this.
Of course once you get into using the socket layer to it's full
potential (and it's full real-world horrors), things will get more
complicated and implementation-dependant...
Regs, Pierre.
--
Pierre Mai <····@acm.org> PGP and GPG keys at your nearest Keyserver
"One smaller motivation which, in part, stems from altruism is Microsoft-
bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]
From: Sam Steingold
Subject: Re: Sending Information Between Lisp & C Program
Date:
Message-ID: <u1z4a3q1q.fsf@ksp.com>
>>>> In message <·················@salford.ac.uk>
>>>> On the subject of "Sending Information Between Lisp & C Program"
>>>> Sent on Tue, 11 Apr 2000 19:39:41 +0100
>>>> Honorable Gary Petley <··········@salford.ac.uk> writes:
>>
>> I was wondering if anyone had some example code or knew of a
>> good web site for introducing me to the delights of sending the
>> output of a lisp program to a program written in C. I believe
>> sockets are good but know nothing about them.
you might find the file clocc/src/port/net.lsp in http://clocc.sourceforge.net
(see also <URL:http://www.podval.org/~sds/data/port.html>) useful.
it helps port socket-using code between different implementations.
code in inspect.lsp, url.lsp, rpm.lsp in clocc/src/cllib (see also
<URL:http://www.podval.org/~sds/data/cllib.html>) uses those functions.
--
Sam Steingold (http://www.podval.org/~sds)
Micros**t is not the answer. Micros**t is a question, and the answer is Linux,
(http://www.linux.org) the choice of the GNU (http://www.gnu.org) generation.
If I had known that it was harmless, I would have killed it myself.