In practice, different tls authenticated kitten visitors will get different abilities, but to start with, the host and the visitor can interact through kitten's database via kitten's dynamic page generation as you are reading here.
For this example, I am running Kitten's `kitten serve` and `kitten shell` from inside of [embeddable common lisp](https://ecl.common-lisp.dev/), which can be freely interleaved into C++ programs. They are being started as [external processes](https://ecl.common-lisp.dev/static/manual/Operating-System-Interface.html#External-processes), and communicated with textually. `kitten shell` uses an (offline javascript) nodejs base. I refered to turning-C++-programs-into-kittens as my [insane kitten fairy godmother theory](/momentary/screwlisps-cl-kitten-future-theory/).
## Lisp `format` and `read-char-no-hang`
I [previously gave an example of reading streams to their end without blocking](/programming/embeddable-common-lisp-external-process-multi-processing-eg/) via [lisp's `read-char-no-hang`](https://www.lispworks.com/reference/HyperSpec/Body/f_rd_c_1.htm).
Here also, I am sending strings to the `kitten shell` via common lisp's format. If you are not using embeddable common lisp, you can send the kitten/shell commands directly to your shell somehow else.
`(format stream "~a~%" "foo")` sends `foo${'๐ฑ'.repeat(kitten.db.numbers.count++) }
`
```
being somewhere between the [kitten dynamic page tutorial](https://kitten.small-web.org/tutorials/dynamic-pages/) and [Kitten persistence tutorial](https://kitten.small-web.org/tutorials/persistence).
Let us use this from lisp at all.
## Embeddable common lisp `ext:run-program "kitten"`
### Setup
```
#|
(eepitch-shell)
cd ~/kittens/dynamicdb
ecl
|#
```
If you are not using *eepitch* I guess you can figure out what you would do.
## Run Kitten inside of ecl - `kitten serve`
Noting we `cd`(1)'d into our directory already, let's use embeddable common lisp's `ext:run-program` to just start serving the kitten.
```
(locally
(declare (special *kit2way* *kitret* *kitproc*))
(multiple-value-setq
(*kit2way* *kitret* *kitproc*)
(ext:run-program "kitten" '("serve")
:wait nil)))
(loop :for ch := (read-char-no-hang
(two-way-stream-input-stream *kit2way*))
:while ch :do (princ ch))
```
### `kitten serve` output
```
ECL (Embeddable Common-Lisp) 21.2.1 (git:UNKNOWN)
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2013 Juan J. Garcia-Ripoll
Copyright (C) 2018 Daniel Kochmanski
Copyright (C) 2021 Daniel Kochmanski and Marius Gerbershagen
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.
Top level in: #
```
```
### (Interactively) set a new value in the kittendb object
```
(format (two-way-stream-output-stream *2way*)
"~a~%"
"kitten.db.numbers.count = 1")
(loop :for ch := (read-char-no-hang
(two-way-stream-input-stream *2way*))
:while ch :do (princ ch))
```
โฌ
```
> (format (two-way-stream-output-stream *2way*)
"~a~%"
"kitten.db.numbers.count = 1")
NIL
>
(loop :for ch := (read-char-no-hang
(two-way-stream-input-stream *2way*))
:while ch :do (princ ch))
kitten.db.numbers.count = 1
1
๐ฑ ๐ฌ (127.0.0.1:41028)
NIL
```
### Get kittendb value
```
(format (two-way-stream-output-stream *2way*)
"~a~%"
"kitten.db.numbers.count")
(loop :for ch := (read-char-no-hang
(two-way-stream-input-stream *2way*))
:while ch :do (princ ch))
```
โฌ
```
> (format (two-way-stream-output-stream *2way*)
"~a~%"
"kitten.db.numbers.count")
NIL
>
(loop :for ch := (read-char-no-hang
(two-way-stream-input-stream *2way*))
:while ch :do (princ ch))
kitten.db.numbers.count
1
๐ฑ ๐ฌ (127.0.0.1:41028)
NIL
```
### Killing the kitten
Unfortunate heading aside.
```
(format (two-way-stream-output-stream *2way*)
"~a~%"
"process.kill(0)")
```
This seems to end up suddenly killing the whole process for me, after which I might as well
```
#|
(eepitch-kill)
|#
```
for good measure.
# Conclusions
Simple host-visitor communication is seen via the visitor hitting a kitten and the host reading and changing the number of kittens on the kittenloads interactively, live in response.
In practice, the host will be a robot system connecting two visitors' interactions (visitor + host๐ค + visitor), but this article showed one-half of the dynamic in interactive practice (host + visitor)
My model for kittens in lisp is to make an [elephant](https://common-lisp.net/project/elephant) out of [kittens using the mop](https://screwlisp.small-web.org/kitten/planning-cl-kitten-mop/).
# Fin.
Kitten steps. What do you think [(on the Mastodon thread please)](https://gamerplus.org/@screwlisp/114708184726530511) about Kitten, lisp, the example interaction, the direction.