I am trying to play with a Swank server from the command line (with no specific production purpose, merely trying to understand things with some hacky ideas in mind for later) and I can't figure out what I can type from a telnet
session for getting any usable answer; for instance how could I evaluate (+ 1 1)
?
A previous question tells:
It is indeed possible to communicate with a swank server if you familiarize yourself with the swank protocol, which seems to be underdocumented (see e. g. here: https://github.com/astine/swank-client/blob/master/swank-description.markdown). However, this exposes a TCP socket over a network, which could be unsafe. Once I tried that, too, but I was not satisfied with the IPC speed.
and the link actually gives some hints, but unfortunately no example. I couldn't get any result.
Here is what I tried; after having separately started a server with
(swank:create-server :port 4005 :dont-close t :style NIL)
I tried things like:
~ $ telnet localhost:4005
00001e(swank:listener-eval (+ 1 2))
and got the following error message:
" "Reader error in file #<string-input stream from \"(swan...\" 0x6045ce0640>, position 20:
Cannot find the external symbol LISTENER-EVAL in #<\"SWANK\" package>.")Connection closed by foreign host
What would be in that case the string I should type?
I managed to make this work:
00003e(:emacs-rex (swank:interactive-eval "(+ 1 2)") "cl-user" t 8)
Notice how there is first an :emacs-rex
keyword, and how the form to evaluate is in a string. The 8 is just an arbitrary value here. The reply first starts with 00A1C8(:indentation-update ...)
, followed by:
000031(:return (:ok "=> 3 (2 bits, #x3, #o3, #b11)") 8)