[Ecls-list] why doesn't my stupid mini http-server run?

fBechmann at t-online.de fBechmann at t-online.de
Wed Nov 9 14:04:03 UTC 2005


I couldn't get it smaller than this:

===

(in-package :cl-user)

(load "sys:sockets")
(use-package :sb-bsd-sockets)

(defmethod handle-client ((socket inet-socket))
    "Handle a client request."
    (let* ( (client-stream (socket-make-stream socket :input t :output t 
:element-type 'character :buffering :full))
            (message (read-line client-stream))
            (response (format nil
                "~A ~D 
~A~%~%<html><head><title>foo</title></head><body>bar!</body></html>~%"
                "HTTP/1.0" 200 "OK"
                )))
            (write-line message)
            (write-line response)
            (write-line response client-stream))
    (write-line "Closing client connection.")
    (socket-close socket))
   
(defun run-http-server (host port)
    (let ((s (make-instance 'inet-socket :type :stream :protocol :tcp)))
        (socket-bind s (make-inet-address host) port)
        (socket-listen s 5)
        (do ((client-socket (socket-accept s) (socket-accept s)))
            (nil)  ; infinite loop
            (write-line "New client")
            (let ((client-socket client-socket))
                (handle-client client-socket)))))

(run-http-server "127.0.0.1" 1975)
;; http://127.0.0.1:1975/foo/bar?bazz=123

===

accessing the URL w/ IE doesn't work at all (no http error, just 'The 
page cannot be displayed').
accessing the URL w/ firefox brings up the page about 4 of 5 times, but 
I also get some 'The document contains no data.'.
the log output is always displayed in the server console.
I'm running ECL fresh from CVS on win2k.

I have no idea what's happening here, anyone else?

TIA and regards,
   frank





More information about the ecl-devel mailing list