Welcome to the CHICKEN Scheme pasting service

how do i close the socket, yet return the result of read-json? pasted by sECuRE on Mon Aug 27 21:10:32 2012

(define (i3-command msg)
  (let ((ipc (socket af/unix sock/stream)))
    (socket-connect ipc (unix-address (i3-socket-path)))
    (socket-send-all ipc (i3-format-ipc-message msg 0))
    (socket-receive ipc (string-length "i3-ipc"))
    (let ((reply-length (with-input-from-string (socket-receive ipc 4) (cut read-u32)))
	  (reply-type (with-input-from-string (socket-receive ipc 4) (cut read-u32))))
      (read-json (socket-receive ipc reply-length)))))
;;    (socket-close ipc)))

return json after closing socket added by mario-goulart on Mon Aug 27 21:13:15 2012

(define (i3-command msg)
  (let ((ipc (socket af/unix sock/stream)))
    (socket-connect ipc (unix-address (i3-socket-path)))
    (socket-send-all ipc (i3-format-ipc-message msg 0))
    (socket-receive ipc (string-length "i3-ipc"))
    (let* ((reply-length (with-input-from-string (socket-receive ipc 4) (cut read-u32)))
	   (reply-type (with-input-from-string (socket-receive ipc 4) (cut read-u32)))
           (json (read-json (socket-receive ipc reply-length))))
      (socket-close ipc)
      json)))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which R5RS procedure can be used to concatenate strings?
Visually impaired? Let me spell it for you (wav file) download WAV