Re: sbcl - how to get a REPL for a created thread?
- From: "Karol Skocik" <Karol.Skocik@xxxxxxxxx>
- Date: 11 Feb 2006 04:28:04 -0800
Glenn, I hope that you can help me with last one thing. Now I can
create more REPLs, but how do I connect some REPL to the input/output
of some thread? I mean :
I have a server, which creates thread for communication with client
like this :
(defun start-server (&key client-function
(port +listener-port+)
(max-connections +listener-max-waiting-connections+))
(when (and (null *listener-thread*) (null *listener-socket*))
(let* ((listener-socket (make-tcp-socket))
(listener-thread (lambda ()
(handler-case
(progn
(setf (sockopt-reuse-address listener-socket) t)
(socket-bind listener-socket sb-bsd-sockets::inet-address-any
port)
(socket-listen listener-socket max-connections)
(loop
(multiple-value-bind (client-socket peer)
(socket-accept listener-socket)
(make-client-thread client-socket peer client-function))))
(socket-error (condition)
(break "Listener socket : ~a" condition)
(socket-close listener-socket)
(setf *listener-socket* nil
*listener-thread* nil))))))
(setf *listener-socket* listener-socket
*listener-thread* (make-thread listener-thread
:name (format nil "tactix listener on port ~a" port))))))
and I have (now only bare bones) of the player-worker like this :
(defun player-worker (socket peer)
(declare (ignore peer))
(handle-socket-errors socket
(let ((str (socket-make-stream socket :input t :output t
:buffering :full :element-type 'unsigned-byte)))
(handler-case
(loop
(format t "playershell> ")
(let ((command (read)))
(format t "~a~%" command)))
; (with-mutex (*shell-mutex*)
; (condition-wait *shell-waitqueue* *shell-mutex*)
; (let ((function-name (car *shell-command*)))
; (apply (funcall function-name)
; (append (list str 0) (cdr *shell-command*))))))
; (apply (car *shell-command*)
; `(,str 0 ,@(cdr *shell-command*)))))
(error ()
(make-condition 'end-of-file
:format-control "connection lost unexpextedly"))))))
I was hoping to change the additional REPL to the one which can read
s-exprs using (read) and output to that reply using (format t "...") -
so I can directly invoke calls on server which communicate with client,
and see what is happening interactively.
How to do that, if it's possible?
Thanks for any ideas,
Karol
.
- Follow-Ups:
- Re: sbcl - how to get a REPL for a created thread?
- From: Glenn . Ehrlich
- Re: sbcl - how to get a REPL for a created thread?
- References:
- sbcl - how to get a REPL for a created thread?
- From: Karol Skocik
- Re: sbcl - how to get a REPL for a created thread?
- From: Glenn . Ehrlich
- sbcl - how to get a REPL for a created thread?
- Prev by Date: Re: How to sum a list?
- Next by Date: Re: beginner question on idiomatic lisp
- Previous by thread: Re: sbcl - how to get a REPL for a created thread?
- Next by thread: Re: sbcl - how to get a REPL for a created thread?
- Index(es):