The Wire and Remote packages for CMU look pretty good,
but I would rather use sockets. I found a nice 10 line client
socket example, so I have the client side covered.
However, I can't find any documentation on using server
side sockets. I would appreciate it if anyone could point
me towards either CMU Lisp socket docs or a short
server side example program.
Thanks!,
Mark
-- Mark Watson (remove _NOSPAM from my email address)
-- www.markwatson.com - Open Source and Java Consulting
> * In message <·····················@newsread2.prod.itd.earthlink.net>
> * On the subject of "Q: CMU Sockets documentation?"
> * Sent on Thu, 21 Jun 2001 21:29:59 GMT
> * Honorable Mark Watson <············@markwatson.com> writes:
>
> However, I can't find any documentation on using server
> side sockets. I would appreciate it if anyone could point
> me towards either CMU Lisp socket docs or a short
> server side example program.
If you use CLOCC/PORT/net.lisp, you would be able to keep your code
portable across several CL implementations.
<http://www.podval.org/~sds/data/port.html>
--
Sam Steingold (http://www.podval.org/~sds)
Never underestimate the power of stupid people in large groups.
MW> [...] However, I can't find any documentation on using server side
MW> sockets. I would appreciate it if anyone could point me
MW> towards either CMU Lisp socket docs or a short server side
MW> example program.
There's a file called internet.lisp in the code directory of the source.
If you've done any sockets work with C before, that'll probably be
enough to get you started.
I hacked something up using that (server included and fork even (holy
COW!)) for Bagley's shootout:
http://www.bagley.org/~doug/shootout/bench/echo/echo.cmucl
I think Daniel Barlow is working on a socket implementation that gives you
more options and UDP. That should be linked from the cliki.
cheers,
BM
Mark Watson <············@markwatson.com> writes:
> However, I can't find any documentation on using server
> side sockets. I would appreciate it if anyone could point
> me towards either CMU Lisp socket docs or a short
> server side example program.
I'm not sure there are any docs. Have you tried looking at the
source? Download a CMUCL source tarchive and look through
src/code/internet.lisp - it's pretty straighforward
-dan
--
http://ww.telent.net/cliki/ - Link farm for free CL-on-Unix resources
Mark Watson <············@markwatson.com> writes:
> The Wire and Remote packages for CMU look pretty good,
> but I would rather use sockets. I found a nice 10 line client
> socket example, so I have the client side covered.
>
> However, I can't find any documentation on using server
> side sockets. I would appreciate it if anyone could point
> me towards either CMU Lisp socket docs or a short
> server side example program.
The source code for CMU CL contains an example lisp listener server,
using multi-processing alongside sockets in the file multi-proc.lisp
(the function start-lisp-connection-listener). Note that this
requires multi-processing, which currently works on x86 only. The
serve-event stuff for other platforms isn't that difficult to do
either, though.
The basic stuff is just calling ext:create-inet-listener, which
returns the socket you listen on for connections. Then, in a tight
loop (for MP), you wait for a new connection using
process-wait-until-fd-usable, then accept it using
ext:accept-tcp-connection, which will give you the new fd for the
connection, and the ip-address of the remote-host. You can now create
an fd-stream wrapping that fd, and create a new process to handle the
connection. E.g.:
(use-package :MP)
(defun silly-listener (port)
(let ((socket (ext:create-inet-listener port)))
(unwind-protect
(loop
;; Wait for a new connection:
(process-wait-until-fd-usable socket :input)
(multiple-value-bind (new-fd remote-host)
(ext:accept-tcp-connection socket)
(let ((stream (sys:make-fd-stream new-fd :input t :output t)))
(make-process #'(lambda () (process-connection stream))))))
(unix:unix-close socket))))
(defun start-silly-listener (port)
(make-process #'(lambda () (silly-listener port))))
Where process-connection is the function that handles the connection
on the given stream, and closes that stream afterwards (which will
close the connection).
Regs, Pierre.
--
Pierre R. Mai <····@acm.org> http://www.pmsf.de/pmai/
The most likely way for the world to be destroyed, most experts agree,
is by accident. That's where we come in; we're computer professionals.
We cause accidents. -- Nathaniel Borenstein