sender   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/nanomsg.xtm

Implementation

(bind-func sender
  (let ((sock (nn_socket AF_SP NN_PUSH)))
    (if (or (< sock 0)
            (< (nn_connect sock "ipc:///tmp/pipeline.ipc") 0))
        (nn_println_strerror))
    (lambda (msg:i8*)
      (let ((sz_msg (+ (strlen msg) 1))
            (bytes (nn_send sock msg sz_msg 0)))
        (if (< bytes 0) ;; should also check (< bytes (convert sz_msg))
            (nn_println_strerror)
            void)))))


Back to Index

Similar Entries