Code Monkey home page Code Monkey logo

zeromq's Introduction

FFI to zeromq

zeromq's People

Contributors

amanda-mitchell avatar djellemah avatar edwardgeorge avatar jeapostrophe avatar mflatt avatar neomantic avatar stamourv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

zeromq's Issues

Can't get translation of peering1 example to work.

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))

socket-recv! not working - "make-sized-byte-string: unsupported"

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)]))))))))

Manual conflict

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.