zeromq / rbzmq

Ruby binding for 0MQ

Home Page:http://www.zeromq.org/bindings:ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please UPDATE gem to work with 0MQ 3.x.x ... current gem won't build w/ 3.0

mistergibson opened this issue · comments

The 3.0 guide is brilliant and I find it humorous. However, if you have a link to the 2.1.x guide - I might get more use out of that.

Currently, this gem will only work with 2.1.x zeromq and won't build on my system with 3.2.x for love or money. ... A lot of "ZMQ_HWM, ZMQ_SWAP, .." undeclared errors.

2.1.x is nice, and it is all good fun until you actually try to follow along at home with the web example code ... Poller? What's that in 2.x.x? That, and the break of API should have got this gem updated some time ago, or at least gotten a zmq3 gem out in the wild by now. Just saying.

-or-

if there is some magic incantation I'm just unaware of ... let me know the secrets of the universe, my gem won't build.

Thanks, and great work on the 3.0 guide - excellent.

Second. Can't get the gem to build. Python is great. I have a reason to use ruby. zeromq 3.2 is stable and recommended for use with new projects, unless those projects are ruby? What's the deal?

Can someone submit a pull request for 3.x support, please?

Or coordinate with 0MQ leadership to take over as maintainer of this gem?

I don't have any active projects using 0MQ at this time and have not been following the 3.x development, so I'm not even really sure what changed.

Would also love to see this fixed.

I pushed some changes to the "zeromq3" topic branch that make the build succeed with version 3.x of the zeromq library. Please test.

Using the zeromq3 branch, the gem builds, but when I try to run the hwclient.rb I get "./hwclient.rb:17:in `send': Socket operation on non-socket (ZMQ::Error)"

The changes I had to make to the hwclient.rb listing in the guide, to get this far, are;

# require 'ffi-rzmq'
require 'zmq'

  # requester.send_string "Hello"
  requester.send "Hello"

@digitalronin did you found already a fix for this issue?

I will put here the errors caused in "gem install zmq" in case someone want to work in a pull request.

ERROR: Error installing zmq:
ERROR: Failed to build gem native extension.

    /Users/paulocheque/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb

checking for zmq.h... yes
checking for zmq_init() in -lzmq... yes
Cool, I found your zmq install...
creating Makefile

make
compiling rbzmq.c
rbzmq.c:968:7: error: use of undeclared identifier 'ZMQ_RECOVERY_IVL_MSEC'
case ZMQ_RECOVERY_IVL_MSEC:
^
rbzmq.c:990:10: error: use of undeclared identifier 'ZMQ_HWM'
case ZMQ_HWM:
^
rbzmq.c:991:10: error: use of undeclared identifier 'ZMQ_SWAP'
case ZMQ_SWAP:
^
rbzmq.c:995:10: error: use of undeclared identifier 'ZMQ_MCAST_LOOP'
case ZMQ_MCAST_LOOP:
^
rbzmq.c:1292:10: error: use of undeclared identifier 'ZMQ_HWM'
case ZMQ_HWM:
^
rbzmq.c:1293:10: error: use of undeclared identifier 'ZMQ_SWAP'
case ZMQ_SWAP:
^
rbzmq.c:1297:10: error: use of undeclared identifier 'ZMQ_MCAST_LOOP'
case ZMQ_MCAST_LOOP:
^
rbzmq.c:1315:10: error: use of undeclared identifier 'ZMQ_RECOVERY_IVL_MSEC'
case ZMQ_RECOVERY_IVL_MSEC:
^
rbzmq.c:1443:81: error: too few arguments to function call, expected 4, have 3
send_args->rc = zmq_send(send_args->socket, send_args->msg, send_args->flags);
~~~~~~~~ ^
/usr/local/include/zmq.h:349:1: note: 'zmq_send' declared here
ZMQ_EXPORT int zmq_send (void *s, const void *buf, size_t len, int flags);
^
/usr/local/include/zmq.h:50:27: note: expanded from macro 'ZMQ_EXPORT'

define ZMQ_EXPORT attribute ((visibility("default")))

                      ^

rbzmq.c:1517:38: error: too few arguments to function call, expected 4, have 3
rc = zmq_send (s, &msg, flags);
~~~~~~~~ ^
/usr/local/include/zmq.h:349:1: note: 'zmq_send' declared here
ZMQ_EXPORT int zmq_send (void *s, const void *buf, size_t len, int flags);
^
/usr/local/include/zmq.h:50:27: note: expanded from macro 'ZMQ_EXPORT'

define ZMQ_EXPORT attribute ((visibility("default")))

                      ^

rbzmq.c:1541:81: error: too few arguments to function call, expected 4, have 3
recv_args->rc = zmq_recv(recv_args->socket, recv_args->msg, recv_args->flags);
~~~~~~~~ ^
/usr/local/include/zmq.h:350:1: note: 'zmq_recv' declared here
ZMQ_EXPORT int zmq_recv (void *s, void *buf, size_t len, int flags);
^
/usr/local/include/zmq.h:50:27: note: expanded from macro 'ZMQ_EXPORT'

define ZMQ_EXPORT attribute ((visibility("default")))

                      ^

rbzmq.c:1602:38: error: too few arguments to function call, expected 4, have 3
rc = zmq_recv (s, &msg, flags);
~~~~~~~~ ^
/usr/local/include/zmq.h:350:1: note: 'zmq_recv' declared here
ZMQ_EXPORT int zmq_recv (void *s, void *buf, size_t len, int flags);
^
/usr/local/include/zmq.h:50:27: note: expanded from macro 'ZMQ_EXPORT'

define ZMQ_EXPORT attribute ((visibility("default")))

                      ^

rbzmq.c:1675:50: error: use of undeclared identifier 'ZMQ_HWM'
rb_define_const (zmq_module, "HWM", INT2NUM (ZMQ_HWM));
^
/Users/paulocheque/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:973:35: note: expanded from macro 'INT2NUM'

define INT2NUM(v) INT2FIX((int)(v))

                              ^

/Users/paulocheque/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:225:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
^
rbzmq.c:1676:51: error: use of undeclared identifier 'ZMQ_SWAP'
rb_define_const (zmq_module, "SWAP", INT2NUM (ZMQ_SWAP));
^
/Users/paulocheque/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:973:35: note: expanded from macro 'INT2NUM'

define INT2NUM(v) INT2FIX((int)(v))

                              ^

/Users/paulocheque/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:225:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
^
rbzmq.c:1683:57: error: use of undeclared identifier 'ZMQ_MCAST_LOOP'
rb_define_const (zmq_module, "MCAST_LOOP", INT2NUM (ZMQ_MCAST_LOOP));
^
/Users/paulocheque/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:973:35: note: expanded from macro 'INT2NUM'

define INT2NUM(v) INT2FIX((int)(v))

                              ^

/Users/paulocheque/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:225:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
^
rbzmq.c:1698:64: error: use of undeclared identifier 'ZMQ_RECOVERY_IVL_MSEC'
rb_define_const (zmq_module, "RECOVERY_IVL_MSEC", INT2NUM (ZMQ_RECOVERY_IVL_MSEC));
^
/Users/paulocheque/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:973:35: note: expanded from macro 'INT2NUM'

define INT2NUM(v) INT2FIX((int)(v))

                              ^

/Users/paulocheque/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:225:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
^
16 errors generated.
make: *** [rbzmq.o] Error 1

I can build from the zeromq3 branch fine, but I'm getting the 'Socket operation on non-socket' error as well. Ruby 1.9.3, 0MQ 3.2.3.

We really need this too, please consider fixing this!

@MSch I'm currently running this gem with no problems, using the version included in the latest pull request I've made. It might work for you guys.

I got a same exception on ruby1.9.3.
i got the lastest pull request,and compiled them, but it doesn't work.
this is my code:

#!/usr/bin/env ruby
#encoding utf-8

require 'rubygems'
require 'zmq'

context = ZMQ::Context.new 1

socket = context.socket ZMQ::REQ

puts 'starting connect a tcp zmq server'

socket.connect('tcp://127.0.0.1:5555')

socket.send 'hello'

@xjmarui What exception did you see? Your code works fine for me.

@jtobin I got a error said 'Socket operation on non-socket'. I merged '#31' this commit, and recompile the rbzmq, it works!!!
I don`t know more about C, but yours request is userful for me.
thanks a lot