jeapostrophe / zeromq Goto Github PK
View Code? Open in Web Editor NEWFFI to zeromq
License: Other
FFI to zeromq
License: Other
FFI to zeromq
To reproduce:
racket peering1.rkt DC1 DC2 & racket peering1.rkt DC2 DC1
It crashes when receiving any message with:
poll!: Resource temporarily unavailable
peering1.rkt:
#lang racket
(require net/zmq)
(define (main myself peers)
(printf "Hello, I am ~a\n" myself)
(define ctxt (context 1))
; State Back-End
(define statebe (socket ctxt 'PUB))
; State Front-End
(define statefe (socket ctxt 'SUB))
(set-socket-option! statefe 'SUBSCRIBE #"")
(define bind-address (format "ipc://~a-state.ipc" myself))
(socket-bind! statebe bind-address)
(for ([p (in-list peers)])
(socket-connect! statefe (format "ipc://~a-state.ipc" p)))
(define poller
(vector (make-poll-item statefe 0 'POLLIN empty)))
(let loop ()
(printf "before polling\n")
(poll! poller 1000)
(printf "after polling\n")
(define revents (poll-item-revents (vector-ref poller 0)))
(if (equal? revents '(POLLIN))
(printf "Received: ~a" (socket-recv! statefe))
(socket-send! statebe
(string->bytes/utf-8
(format "~a ~a" bind-address (random 10)))))
(loop))
(context-close! ctxt))
(command-line #:program "peering1"
#:args (myself . peers)
(main myself peers))
This uses the doc name zmq
which conflicts with the doc for the "zmq"
pkg. It should change to use zeromq
in line with the name of the package.
I'm having trouble using the socket-recv!
function. Whenever I try to invoke it, I get the following error:
make-sized-byte-string: unsupported
Here's a minimal code example for how I'm trying to use it:
(define (run-zmq-server port)
(call-with-context (λ (ctx)
(call-with-socket ctx 'PULL (λ (socket)
(socket-bind! socket (format "tcp://127.0.0.1:~a" port))
(display (format "Started mock CE Service on port ~a.\n" port))
(let loop ()
(let* ([dto-bytes (socket-recv! socket)] ; <--- The error is getting thrown here.
[req (_bytes->dto dto-bytes)]
[msg-type (hash-ref req 'messageType #f)])
(cond
[(equal? msg-type 'CLOSE)
(display "Closing mock CE Service.\n")]
[else
(display (format "Received message:\n~a\n\n" msg-type))
(loop)]))))))))
I found out in booksbyus/zguide#638 that these bindings only support zeromq up to 3.x. Please consider adding support for zeromq 4.x.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.