[cl-plus-ssl-devel] trouble wrapping iolib (gray) streams in a web server

Attila Lendvai attila.lendvai at gmail.com
Tue May 3 09:22:54 UTC 2011


> the trivial-sockets based http server in examples.lisp works fine, but
> i get the error pasted below when using iolib streams.

forgot to paste the example code for iolib:

(defun test-https-server
    (&key (port 8080)
	  (cert "/home/david/newcert.pem")
	  (key "/home/david/newkey.pem"))
  (format t "~&SSL server listening on port ~d~%" port)
  (let ((server-socket (iolib:make-socket :connect :passive
:local-host iolib.sockets:+any-host+ :local-port port
                                          :external-format :utf-8
:reuse-address t)))
    (unwind-protect
         (loop
           (let ((socket (iolib:accept-connection server-socket :wait t)))
             (unwind-protect
                  (let ((client (cl+ssl:make-ssl-server-stream
                                 socket
                                 :external-format '(:iso-8859-1 :eol-style :lf)
                                 :certificate cert
                                 :key key)))
                    (unwind-protect
                         (progn
                           (loop :for line = (read-line-crlf client nil)
                             :while (> (length line) 1) :do
                             (format t "HTTPS> ~a~%" line))
                           (format client "HTTP/1.0 200 OK~%")
                           (format client "Server: SSL-CMUCL/1.1~%")
                           (format client "Content-Type: text/plain~%")
                           (terpri client)
                           (format client "G'day at ~A!~%"
                                   (multiple-value-list (get-decoded-time)))
                           (format client "CL+SSL running in ~A ~A~%"
                                   (lisp-implementation-type)
                                   (lisp-implementation-version)))
                      (close client)))
               (close socket))))
      (close server-socket))))


-- 
 attila

Notice your eroding (digital) freedom, and do something about it!

PGP: 2FA1 A9DC 9C1E BA25 A59C  963F 5D5F 45C7 DFCD 0A39
OTR XMPP: 8647EEAC EA30FEEF E1B55146 573E52EE 21B1FF06
BitCoin: 154uf86Vd9rpjMULd9CXa7nVwikknYZJiB




More information about the cl-plus-ssl-devel mailing list