Hi all,
My first problem is with run-program. It's supposed to take an output
parameter with a stream. I have wrapped it inside a string stream thus:
[6]> (with-output-to-string (stream) (run-program "ls" :output stream))
But I get this error when I try to run that:
*** - STRING: argument #<OUTPUT STRING-OUTPUT-STREAM> should be a string,
a symbol or a character
The following restarts are available:
USE-VALUE :R1 You may input a value to be used instead.
The same happens in the Linux build of Clisp. I don't understand why the
Clisp man page says it takes a stream argument.
http://clisp.cons.org/impnotes/shell.html
This fails too:
" [15]> (with-output-to-string (stream) (run-program "ls" :output
:stream stream))
*** - RUN-PROGRAM: keyword arguments in (:OUTPUT :STREAM #<OUTPUT
STRING-OUTPUT-STREAM>) should occur pairwise"
"ls" is just an example function call (I have Cygwin installed). Really,
I want to use it to grab data from a call to an external C program.
I'm also having a problem with Clisp and its internal socket support.
In the example at the bottom of this page:
http://library.n0i.net/programming/lisp/co_cook/sockets.html#example
I start the server, and that runs okay, then (on the same machine, or
across my network from my other PC), I start the client. I send a HTML
request:
(http-get "localhost" 8080 "/myfile.txt")
It sends some of the file, then the client reports a Winsock error, that
the connection was reset by peer. It seems the server's "force-output" is
being completely ignored.
I've tried to figure out how to make the accepted socket block, but all I
can find on the subject is a quite awful Clisp manual page which gives no
examples and nothing is particularly clear.
http://clisp.cons.org/impnotes/socket.html
My system specs are Clisp, latest version 2.35 (or 2.33), Windows XP Pro,
and Zonealarm (a memory-hogging firewall) turned off.
Thanks for any tips. I don't want anyone going off on a limb to solve
these 2 problems, but if anyone knows why it isn't working, please tell
me!
Thanks,
Jeremy.
From: Edi Weitz
Subject: Re: Double trouble with Clisp on Windows - run-program and sockets
Date:
Message-ID: <uhdbvlobx.fsf@agharta.de>
On Wed, 05 Oct 2005 19:44:01 GMT, Jeremy Smith <············@decompiler.org> wrote:
> My first problem is with run-program. It's supposed to take an
> output parameter with a stream. I have wrapped it inside a string
> stream thus:
>
> [6]> (with-output-to-string (stream) (run-program "ls" :output stream))
>
> But I get this error when I try to run that:
>
> *** - STRING: argument #<OUTPUT STRING-OUTPUT-STREAM> should be a string,
> a symbol or a character
> The following restarts are available:
> USE-VALUE :R1 You may input a value to be used instead.
>
> The same happens in the Linux build of Clisp. I don't understand why
> the Clisp man page says it takes a stream argument.
>
> http://clisp.cons.org/impnotes/shell.html
>
> This fails too:
>
> " [15]> (with-output-to-string (stream) (run-program "ls" :output
> :stream stream))
>
> *** - RUN-PROGRAM: keyword arguments in (:OUTPUT :STREAM #<OUTPUT
> STRING-OUTPUT-STREAM>) should occur pairwise"
>
> "ls" is just an example function call (I have Cygwin
> installed). Really, I want to use it to grab data from a call to an
> external C program.
CL-USER> (run-program "ls" :output :stream)
#<INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER 5896>
CL-USER> (loop for line = (read-line * nil nil) while line collect line)
("Groucho.lnk" "Lisp.lnk" "RDNZL" "SQLIte" "backup" "build.bat.lnk" "downloads"
"home" "p650-lehman.pdf" "pack.bat.lnk" "postgresql-8.0.4" "shared")
Cheers,
Edi.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Edi Weitz
Subject: Re: Double trouble with Clisp on Windows - run-program and sockets
Date:
Message-ID: <ud5mjlo3t.fsf@agharta.de>
On Wed, 05 Oct 2005 19:44:01 GMT, Jeremy Smith <············@decompiler.org> wrote:
> http://library.n0i.net/programming/lisp/co_cook/sockets.html#example
It probably doesn't matter in this particular case but note that the
website you're referring to hosts an old version of the CL Cookbook.
The current version is always here:
<http://cl-cookbook.sf.net/>
Cheers,
Edi.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Sam Steingold
Subject: Re: Double trouble with Clisp on Windows - run-program and sockets
Date:
Message-ID: <uirwb8hgi.fsf@gnu.org>
> * Jeremy Smith <············@qrpbzcvyre.bet> [2005-10-05 19:44:01 +0000]:
>
> [6]> (with-output-to-string (stream) (run-program "ls" :output stream))
>
> But I get this error when I try to run that:
>
> *** - STRING: argument #<OUTPUT STRING-OUTPUT-STREAM> should be a string,
> a symbol or a character
> The following restarts are available:
> USE-VALUE :R1 You may input a value to be used instead.
>
> The same happens in the Linux build of Clisp. I don't understand why
> the Clisp man page says it takes a stream argument.
> http://clisp.cons.org/impnotes/shell.html
it does not. please read it again.
> I've tried to figure out how to make the accepted socket block,
if you have a clear idea what you are trying to do (like what syscall
you want to invoke), you might want to share that insight.
--
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.savegushkatif.org> <http://www.dhimmi.com/>
<http://ffii.org/> <http://www.iris.org.il> <http://www.palestinefacts.org/>
MS: Brain off-line, please wait.
>> The same happens in the Linux build of Clisp. I don't understand why
>> the Clisp man page says it takes a stream argument.
>> http://clisp.cons.org/impnotes/shell.html
>
> it does not. please read it again.
Hi,
You're right, I didn't realise the function returns a stream to be read
from, rather than accepting one. It doesn't seem intuitive, and I'm quite
used to using C, so my expectations of what should happen got in the way of
what it said.
Thanks to Edi Weitz for the help!
>> I've tried to figure out how to make the accepted socket block,
>
> if you have a clear idea what you are trying to do (like what syscall
> you want to invoke), you might want to share that insight.
I just wanted to get that example working, and send a file over a socket on
request (using HTTP) on CLisp. The socket kept resetting before the data
was sent, even using Force-output. However, now I've tested it on Linux and
it does exactly the same thing, so I'm not sure what the problem is.
Cheers,
Jeremy.
From: Sam Steingold
Subject: Re: Double trouble with Clisp on Windows - run-program and sockets
Date:
Message-ID: <u4q7qipzr.fsf@gnu.org>
> * Jeremy Smith <············@qrpbzcvyre.bet> [2005-10-09 16:12:53 +0000]:
>
>>> I've tried to figure out how to make the accepted socket block,
>>
>> if you have a clear idea what you are trying to do (like what syscall
>> you want to invoke), you might want to share that insight.
>
> I just wanted to get that example working, and send a file over a
> socket on request (using HTTP) on CLisp. The socket kept resetting
> before the data was sent, even using Force-output. However, now I've
> tested it on Linux and it does exactly the same thing, so I'm not sure
> what the problem is.
I still don't get it what you meant by "make the accepted socket block".
it would help if you filed a detailed bug report on SF (including "what
you did", "what CLISP did", "what you expected" &c &c &c)
PS. do the examples in
http://www.podval.org/~sds/clisp/impnotes/socket.html
work for you?
--
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.palestinefacts.org/> <http://www.camera.org> <http://ffii.org/>
<http://www.iris.org.il> <http://www.dhimmi.com/> <http://pmw.org.il/>
If You Want Breakfast In Bed, Sleep In the Kitchen.
Sam Steingold <···@gnu.org> wrote in ··················@gnu.org:
>> I just wanted to get that example working, and send a file over a
>> socket on request (using HTTP) on CLisp. The socket kept resetting
>> before the data was sent, even using Force-output. However, now I've
>> tested it on Linux and it does exactly the same thing, so I'm not
>> sure what the problem is.
>
> I still don't get it what you meant by "make the accepted socket
> block". it would help if you filed a detailed bug report on SF
> (including "what you did", "what CLISP did", "what you expected" &c &c
> &c)
Sorry, what I mean by 'block' is that when you receive some data from a
socket, if the socket is set to 'block' the code calling the receive
function (on that socket) will wait until the data is received. The same
goes for the other end of the connection (sending data). If it is non-
blocking, the program will continue before the receive or send is
complete.
The code I used from the Lisp Cookbook appears to close the socket (from
the server's end) before the transfer of a file is complete.
It was my suspicion that Clisp wasn't making the socket block properly
due to the behaviour of Winsock, but I'm not too sure about this because
it does this on Linux too.
> PS. do the examples in
> http://www.podval.org/~sds/clisp/impnotes/socket.html
> work for you?
Wget works with the Google index page, and the server also works.
However, when I run the Lisp Cookbook HTTP server in one instance of
Clisp (modified to accept HTTP 1 filenames instead of the fake 0.9 it
uses), and Wget in another, I get the "Connection reset by peer" error
again. This is because the server is closing the socket before the data
is fully transferred to the requesting client, even though the server
calls force-output.
I'll submit a bug report to the Clisp mailing list, but to summarise it
here, in Clisp, the Lisp Cookbook client/server example isn't working
properly. force-output (called on the server side) doesn't seem to wait
for socket streams to finish transferring data, resulting in a partially
transferred stream, which is cut off before it has finished transferring.
Whether the problem is server-side or client-side, I don't know. It's
easily reproducible, so hopefully that bug report will do the trick.
Cheers,
Jeremy.
> I just wanted to get that example working, and send a file over a
> socket on request (using HTTP) on CLisp. The socket kept resetting
> before the data was sent, even using Force-output. However, now I've
> tested it on Linux and it does exactly the same thing, so I'm not sure
> what the problem is.
Hi,
I wrote a bug report and tried to reproduce the problem, step by step, and
in the end, I found that rewriting the server code seemed to fix the
problem. The file transferred properly, and it seemed that "(close
socket)" in the server, after the transfer, was happening before the
transfer was complete, so I took it out and added a special line after the
transfer, to say to the client "transfer has finished", which is actually
quite common in socket programming.
Sorry to Sam Steingold, for thinking it was an error in Clisp. I find Clisp
to be a great Lisp to use!
Cheers,
Jeremy.
From: Edi Weitz
Subject: Re: Double trouble with Clisp on Windows - run-program and sockets
Date:
Message-ID: <uvf05n710.fsf@agharta.de>
On Mon, 10 Oct 2005 00:58:35 GMT, Jeremy Smith <············@decompiler.org> wrote:
> I wrote a bug report and tried to reproduce the problem, step by
> step, and in the end, I found that rewriting the server code seemed
> to fix the problem.
Which means there's an error in the cookbook example? Then you should
report it there... :)
Cheers,
Edi.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq ·········@agharta.de" 5) "edi")