This repository was archived by the owner on Sep 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbucket.lisp
More file actions
42 lines (37 loc) · 1.22 KB
/
bucket.lisp
File metadata and controls
42 lines (37 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(in-package :lisp-mush)
(defun handle-connection (client)
(with-open-socket (client)
(let* ((stream (socket-make-stream client :input t :output t :external-format :latin-1))
(telnet-io (make-instance 'telnet-stream :stream stream))
(*standard-input* telnet-io)
(*standard-output* telnet-io))
(format t "lisp-mush 1.0~%")
(finish-output)
(loop
(format t "> ")
(finish-output)
(handler-case
(handler-bind
((warning (lambda (w)
(format telnet-io "warning: ~A~%" w))))
(let ((line (read-line)))
(eval-argument (make-string-input-stream line) *standard-output*)
(terpri)
(finish-output)))
(end-of-file (c)
(declare (ignore c))
(return))
(condition (c)
(format telnet-io "error: ~A~%" c)
(finish-output (telnet-stream telnet-io)))
)))))
(defun listen-loop (server)
(let* ((client (sb-bsd-sockets:socket-accept server)))
(handle-connection client))
(listen-loop server))
(defun main ()
(with-server (server :port 1701)
(format t "Listening...~%")
(listen-loop server)))
(eval-when (:execute)
(main))