Skip to content

Instantly share code, notes, and snippets.

@carboleum
Last active January 4, 2022 23:10
Show Gist options
  • Save carboleum/f68c984314cdfdfa856dec3f2494d4b2 to your computer and use it in GitHub Desktop.
Save carboleum/f68c984314cdfdfa856dec3f2494d4b2 to your computer and use it in GitHub Desktop.
How to write a message in another terminal (with Common Lisp) ?

How to write a message in another terminal (with Common Lisp) ?

(following the Reddit thread https://www.reddit.com/r/emacs/comments/hap72j/isnt_it_possible_to_ask_emacs_for_a_carriage/fv60gwq)

Install packages

apt install build-essential
apt install libfixposix3 libfixposix-dev
apt install netcat

Open 2 terminals

Terminal 1: Use Netcat to listen the port 6007

nc -l -p 6007

Terminal 2: Open stream in your favorite Common Lisp implementation

(tested with SBCL)

(ql:quickload :iolib/trivial-sockets)
(defparameter *console* (iolib/trivial-sockets:open-stream "127.0.0.1" 6007))
(print "Hello world!" *console*)
(finish-output *console*)
(let ((name "Boris"))
     (format *console* "~%How are you, ~A ?" name))
(finish-output *console*)

Back to terminal 1: Read the nice mesage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment