Skip to content

Instantly share code, notes, and snippets.

@bo-tato
Created April 29, 2023 12:14
Show Gist options
  • Save bo-tato/2940a129d7c870423ab97a350fdaafdc to your computer and use it in GitHub Desktop.
Save bo-tato/2940a129d7c870423ab97a350fdaafdc to your computer and use it in GitHub Desktop.
(use-package 'sb-bsd-sockets)
(defparameter *socket*
(make-instance 'inet-socket :type :stream :protocol :tcp))
(socket-connect *socket* #(127 0 0 1) 1234)
(sb-thread:make-thread
(lambda ()
(loop for buffer = (socket-receive *socket* nil 1)
for c = (elt buffer 0)
while (char/= c #\Nul)
do (write-char c)))
:name "socket reader thread")
(socket-shutdown *socket* :direction :io)
(socket-close *socket*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment