(bind-func nonblocking_read_loop
  (let ((buflen:i64 1024)
        (buf:i8* (zalloc buflen))
        (continue #t))
    (lambda ()
      (if (< REPLY_SOCKET 0)
          (nn_println_strerror)
          (let ((nbytes (nn_recv REPLY_SOCKET buf buflen NN_DONTWAIT)))
            ;; if we get some bytes, trigger the callback
            (if (> nbytes 0)
                (send_response buf nbytes))))
      (if continue
          (callback (+ (now) 1000) nonblocking_read_loop)
          (begin
            (println "stopping nonblocking_read_loop")
            0)))))