Skip to content

Instantly share code, notes, and snippets.

@rfolland
Created December 14, 2018 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfolland/6458fcce83c73c4645cf8793771e1d75 to your computer and use it in GitHub Desktop.
Save rfolland/6458fcce83c73c4645cf8793771e1d75 to your computer and use it in GitHub Desktop.
Write JSON string to a UNIX domain socket
This works:
echo '{"command" : ["set_property", "pause", "yes"] }' | socat - /tmp/DP-1-sock
This does not:
(defun pause-yes ()
(ccl:with-open-socket (socket :connect :active
:address-family :file
:type :stream
:remote-filename "/tmp/DP-1-sock")
(format socket "{\"command\":[\"set_property\", \"pause\", \"yes\"]}")))
@rfolland
Copy link
Author

I also tried this with no success:

(defun pause2 ()
(with-input-from-string (stream "{"command":["set_property", "pause", "yes"]}")
(ccl:run-program "socat" (list "-" "/tmp/DP-1-sock")
:input stream
:output t)))

@rfolland
Copy link
Author

Adding ~& for a newline at the end of the string fixed it (for pause-yes).

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