Created
December 24, 2015 22:38
-
-
Save yehohanan7/47de8c53fe0a0e742b3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun write-bytes (value n stream) | |
(loop for i from (/ n 8) downto 1 | |
do (write-byte (ldb (byte 8 (* (1- i) 8)) value) stream))) | |
(defun zk-connect (host port) | |
(let* ((socket (usocket:socket-connect host port :element-type '(unsigned-byte 8))) | |
(stream (usocket:socket-stream socket)) | |
(protocol-version 0) | |
(last-zxid 0) | |
(timeout 10000) | |
(session-id 0) | |
(password (flexi-streams:string-to-octets (make-string 16 :initial-element (code-char 0))))) | |
(write-bytes protocol-version 32 stream) | |
(write-bytes last-zxid 64 stream) | |
(write-bytes timeout 32 stream) | |
(write-bytes session-id 64 stream) | |
(write-sequence password stream) | |
(force-output stream) | |
(read-byte stream))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment