You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
6 years ago
|
|
||
|
|
||
|
(let ((*standard-output* (make-broadcast-stream)))
|
||
|
(ql:quickload :cl-sipc))
|
||
|
|
||
|
(defparameter *socket-file* "sipc.socket")
|
||
|
|
||
|
(defun help (&optional (st t))
|
||
|
(format t "Available commands:~% (send hello-world)~% (send-binary hello-world)~% (close)~% (rebind \"socket-file.socket\")~% help~% quit~%")
|
||
|
(when st
|
||
|
(format t "(bound to \"~a\")~%" *socket-file*))
|
||
|
'unknown-command)
|
||
|
|
||
|
(format t "Working with socket \"~a\"~%" *socket-file*)
|
||
|
(help nil)
|
||
|
|
||
|
(loop while t do
|
||
|
(let ((rd (progn
|
||
|
(format t "> ")
|
||
|
(force-output)
|
||
|
(read))))
|
||
|
(and (atom rd)
|
||
|
(eql rd 'quit)
|
||
|
(quit))
|
||
|
(print (and (not (atom rd))
|
||
|
(cond ((eql (car rd) 'send) (sipc:send-quick *socket-file* (if (stringp (cadr rd))
|
||
|
(cadr rd)
|
||
|
(write-to-string (cadr rd))) :string))
|
||
|
((eql (car rd) 'send-binary) (sipc:send-quick *socket-file* (if (stringp (cadr rd))
|
||
|
(cadr rd)
|
||
|
(write-to-string (cadr rd))) :binary))
|
||
|
((eql (car rd) 'close) (sipc:send-quick *socket-file* nil :close))
|
||
|
((eql (car rd) 'rebind) (setf *socket-file* (cadr rd)))
|
||
|
(t (help)))))
|
||
|
(format t "~%")
|
||
|
(and (atom rd)
|
||
|
(help))))
|