(defvar *talk-port* 10244) ; a free TCP port number

(defun TALKING-TO-MYSELF ()  
  (with-open-stream       
   (talk 
    (comm:open-tcp-stream "localhost"                                   
			  *talk-port*))    
   (loop for  monolog in  '( "(s / sail)"               
			     "(s / sail :actor (p / ship))")
	 do
	 (write-line monolog talk)      
	 (force-output talk)      
	 (format t "I said: \"~A\"~%" monolog)     
	 (format t "Self replied: \"~A\"~%" 
		 (read-line talk nil nil)))))


(defun kpml-say (spl)
  (with-open-stream
   (talk
    (comm:open-tcp-stream "localhost"
			  *talk-port*))
   (write-line 
    (format nil "~S" spl)
    talk)
   (force-output talk)
   (read-from-string
    (read-line talk nil nil))))