zeromq / rbzmq Goto Github PK
View Code? Open in Web Editor NEWRuby binding for 0MQ
Home Page: http://www.zeromq.org/bindings:ruby
Ruby binding for 0MQ
Home Page: http://www.zeromq.org/bindings:ruby
Caute borci,
I have a following issue on Debian stable using libzmq 2.1.10-1 compiled from unstable, so I am not sure if it goes on account of Ruby bindings or zmq library itself. ruby-1.9.2-p290 hangs when running an example from README.rdoc. Here is a stack of all threads.
(gdb) bt
#0 0xb78b8424 in __kernel_vsyscall ()
#1 0xb75a9696 in poll () from /lib/i686/cmov/libc.so.6
#2 0xb72bbc7b in zmq::signaler_t::wait (this=0x8c53338, timeout_=-1) at signaler.cpp:145
#3 0xb72ac75b in zmq::mailbox_t::recv (this=0x8c53308, cmd_=0xbfa0ab78, timeout_=-1) at mailbox.cpp:69
#4 0xb72a5322 in zmq::ctx_t::terminate (this=0x8c532b8) at ctx.cpp:146
#5 0xb72c7808 in zmq_term (ctx_=0x8c532b8) at zmq.cpp:292
#6 0xb76c15e1 in context_free (ctx=0xfffffdfc) at rbzmq.c:98
#7 0xb7733b9a in run_final (objspace=0x8aa6440) at gc.c:2605
#8 finalize_list (objspace=0x8aa6440) at gc.c:1808
#9 rb_objspace_call_finalizer (objspace=0x8aa6440) at gc.c:2743
#10 0xb77210ee in ruby_finalize_1 (ex=0) at eval.c:111
#11 ruby_cleanup (ex=0) at eval.c:161
#12 0xb772132d in ruby_run_node (n=0x8ac07e4) at eval.c:254
#13 0x080487d8 in main (argc=4, argv=0xbfa0ae84) at main.c:35
(gdb) info threads
3 Thread 0xb7131b70 (LWP 6058) 0xb78b8424 in __kernel_vsyscall ()
2 Thread 0xb6930b70 (LWP 6059) 0xb78b8424 in __kernel_vsyscall ()
* 1 Thread 0xb74ea6c0 (LWP 6056) 0xb78b8424 in __kernel_vsyscall ()
(gdb) thread 2
[Switching to thread 2 (Thread 0xb6930b70 (LWP 6059))]#0 0xb78b8424 in __kernel_vsyscall ()
(gdb) bt
#0 0xb78b8424 in __kernel_vsyscall ()
#1 0xb75b76f6 in epoll_wait () from /lib/i686/cmov/libc.so.6
#2 0xb72a90e6 in zmq::epoll_t::loop (this=0x8c8e688) at epoll.cpp:142
#3 0xb72c2426 in thread_routine (arg_=0x8c8e6cc) at thread.cpp:75
#4 0xb769c955 in start_thread () from /lib/i686/cmov/libpthread.so.0
#5 0xb75b6e7e in clone () from /lib/i686/cmov/libc.so.6
(gdb) thread 3
[Switching to thread 3 (Thread 0xb7131b70 (LWP 6058))]#0 0xb78b8424 in __kernel_vsyscall ()
(gdb) bt
#0 0xb78b8424 in __kernel_vsyscall ()
#1 0xb75b76f6 in epoll_wait () from /lib/i686/cmov/libc.so.6
#2 0xb72a90e6 in zmq::epoll_t::loop (this=0x8c95ce8) at epoll.cpp:142
#3 0xb72c2426 in thread_routine (arg_=0x8c95d2c) at thread.cpp:75
#4 0xb769c955 in start_thread () from /lib/i686/cmov/libpthread.so.0
#5 0xb75b6e7e in clone () from /lib/i686/cmov/libc.so.6
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: In function ‘context_initialize’:
rbzmq.c:126: warning: ISO C90 forbids mixed declarations and code
rbzmq.c: In function ‘poll_add_item’:
rbzmq.c:219: warning: ISO C90 forbids mixed declarations and code
rbzmq.c:232: warning: ISO C90 forbids mixed declarations and code
rbzmq.c: In function ‘internal_select’:
rbzmq.c:338: warning: ISO C90 forbids mixed declarations and code
rbzmq.c: In function ‘module_select’:
rbzmq.c:388: warning: ISO C90 forbids mixed declarations and code
rbzmq.c: In function ‘context_socket’:
rbzmq.c:431: warning: ISO C90 forbids mixed declarations and code
rbzmq.c: In function ‘socket_getsockopt’:
rbzmq.c:968: error: ‘ZMQ_RECOVERY_IVL_MSEC’ undeclared (first use in this function)
rbzmq.c:968: error: (Each undeclared identifier is reported only once
rbzmq.c:968: error: for each function it appears in.)
rbzmq.c:990: error: ‘ZMQ_HWM’ undeclared (first use in this function)
rbzmq.c:991: error: ‘ZMQ_SWAP’ undeclared (first use in this function)
rbzmq.c:995: error: ‘ZMQ_MCAST_LOOP’ undeclared (first use in this function)
rbzmq.c: In function ‘socket_setsockopt’:
rbzmq.c:1292: error: ‘ZMQ_HWM’ undeclared (first use in this function)
rbzmq.c:1293: error: ‘ZMQ_SWAP’ undeclared (first use in this function)
rbzmq.c:1297: error: ‘ZMQ_MCAST_LOOP’ undeclared (first use in this function)
rbzmq.c:1315: error: ‘ZMQ_RECOVERY_IVL_MSEC’ undeclared (first use in this function)
rbzmq.c: In function ‘socket_bind’:
rbzmq.c:1379: warning: ISO C90 forbids mixed declarations and code
rbzmq.c: In function ‘socket_connect’:
rbzmq.c:1422: warning: ISO C90 forbids mixed declarations and code
rbzmq.c: In function ‘zmq_send_blocking’:
rbzmq.c:1443: error: too few arguments to function ‘zmq_send’
rbzmq.c: In function ‘socket_send’:
rbzmq.c:1490: warning: ISO C90 forbids mixed declarations and code
rbzmq.c:1496: warning: ISO C90 forbids mixed declarations and code
rbzmq.c:1517: error: too few arguments to function ‘zmq_send’
rbzmq.c: In function ‘zmq_recv_blocking’:
rbzmq.c:1541: error: too few arguments to function ‘zmq_recv’
rbzmq.c: In function ‘socket_recv’:
rbzmq.c:1580: warning: ISO C90 forbids mixed declarations and code
rbzmq.c:1584: warning: ISO C90 forbids mixed declarations and code
rbzmq.c:1602: error: too few arguments to function ‘zmq_recv’
rbzmq.c:1616: warning: ISO C90 forbids mixed declarations and code
rbzmq.c: In function ‘Init_zmq’:
rbzmq.c:1658: warning: ISO C90 forbids mixed declarations and code
rbzmq.c:1675: error: ‘ZMQ_HWM’ undeclared (first use in this function)
rbzmq.c:1676: error: ‘ZMQ_SWAP’ undeclared (first use in this function)
rbzmq.c:1683: error: ‘ZMQ_MCAST_LOOP’ undeclared (first use in this function)
rbzmq.c:1698: error: ‘ZMQ_RECOVERY_IVL_MSEC’ undeclared (first use in this function)
make: *** [rbzmq.o] Error 1
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.
With ruby 1.8.7, zmq 2.1.7 and rbzmq 2.1.3, I notice that rbzmq has signal handling problem.
With ruby 1.9.2, this problem is not occurred.
Reproduction code is below.
require 'rubygems'
require 'zmq'
c = ZMQ::Context.new
s = c.socket(ZMQ::PULL)
s.bind('ipc:///tmp/a')
begin
puts s.recv
ensure
$stderr.puts 'ensure'
s.close
c.close
end
When I input Ctrl-c and terminate this program while blocking in s.recv,
I expect the ensure closure is run and 'ensure' is shown in the terminal but actual output is below.
$ ruby intr.rb
^Cintr.rb:11: Interrupt
The line number of Interrupt is strange. Line 11 is '$stderr.puts ...'.
I think EINTR is ignored because ruby vm will handle it.
I've created a small patch for socket_recv. It seems fine but I don't know whether this is the best way.
diff --git a/rbzmq.c b/rbzmq.c
index 8164c93..d1929fc 100644
--- a/rbzmq.c
+++ b/rbzmq.c
@@ -1603,7 +1603,7 @@ static VALUE socket_recv (int argc_, VALUE* argv_, VALUE self_)
else
#endif
rc = zmq_recv (s, &msg, flags);
- if (rc != 0 && zmq_errno () == EAGAIN) {
+ if (rc != 0 && zmq_errno () == EAGAIN || zmq_errno () == EINTR) {
rc = zmq_msg_close (&msg);
assert (rc == 0);
return Qnil;
I have a scenario of REQ/ REP where the replier keeps polling for any requests coming from the requester using the standard poller apis.
we have a ruby implementation of the above scenario.
The issue we are facing is that the above scenario works only with the ipc
protocol and not with the tcp
protocol(in the bind and connect urls of replier and requester respectively).
However if we go by the standard requester / replier with the send/receive function then the whole process works well with the tcp
and ipc
protocol both.
The issue happens on changing the the replier code to the poller implementation and the requester/replier are not able to communicate with each other.
We also tried out the corresponding C++ implementation and it seems to work fine for both tcp
/ipc
protocols and both standard/poller implementations
I want to know if there is any important part missing in the code or some OS setting that needs to be changed to get the ruby code working with the poller implementation?
RUBY implementation
REQUESTER
require 'rubygems'
require 'ffi-rzmq'
context = ZMQ::Context.new
puts "Connecting to the Server..."
requester = context.socket(ZMQ::REQ)
requester.connect("tcp://localhost:5555")
puts "Calling server"
requester.send_string 'Shiraaz'
puts 'After send'
reply = ''
requester.recv_string(reply)
puts 'After receieve'
puts reply
REPLIER with standard receive/send implementation
require 'rubygems'
require 'ffi-rzmq'
context = ZMQ::Context.new
puts "Connecting to the Server..."
requester = context.socket(ZMQ::REQ)
requester.connect("tcp://localhost:5555")
puts "Calling server"
requester.send_string 'Shiraaz'
puts 'After send'
reply = ''
requester.recv_string(reply)
puts 'After receieve'
puts reply
REPLIER with poller implementation
require 'rubygems'
require 'ffi-rzmq'
puts "Starting Server..."
context = ZMQ::Context.new
socket = context.socket(ZMQ::REP)
socket.bind("tcp://localhost:5555") //This does not works...But changing it to socket.bind("ipc:///tmp/feed") and making the same change in the requester connect url makes it work
poller = ZMQ::Poller.new
poller.register(socket, ZMQ::POLLIN)
loop do
puts 'Before poll'
poller.poll(1000)
request = ''
puts 'After poll'
poller.readables.each do |sock|
puts 'here'
if sock === socket
sock.recv_string(request)
puts "Received request. Data: #{request.inspect}"
sock.send_string('Reply from the server')
end
end
end
Version info:-
ruby : 1.8.7
rubygems : 1.8.25
ffi : 1.0.10
ffi-rzmq : 0.9.7
OS : rhel 7.2
g++ : 4.8.5
zmq : 3.2.5-1.el7
I've got a 'cutting edge' setup and I'm trying running in to the most basic issues. I have a subscribing ZMQ process elsewhere and I'm trying to get a pull socket up and running
irb(main):012:0> ctx = ZMQ::Context.new(1)
=> #<ZMQ::Context:0xb9108358>
irb(main):013:0> socket = ctx.socket(ZMQ::PULL)
=> #<ZMQ::Socket:0xb90fbe3c>
irb(main):014:0> socket.recv
ZMQ::Error: Socket operation on non-socket
from (irb):14:in `recv'
from (irb):14
from /usr/local/bin/irb:12:in `<main>'
Am I using the API incorrectly?
gem install zmq
Building native extensions. This could take a while...
ERROR: Error installing zmq:
ERROR: Failed to build gem native extension.
/home/rajeevkannav/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for zmq.h... no
checking for zmq.h in /opt/local/include,/usr/local/include,/usr/include... no
extconf.rb:36:in `
Gem files will remain installed in /home/rajeevkannav/.rvm/gems/[email protected]/gems/zmq-2.1.4 for inspection.
Results logged to /home/rajeevkannav/.rvm/gems/[email protected]/gems/zmq-2.1.4/./gem_make.out
I downloaded ruby sources and compiled ruby from it
After that I downloaded zmq from sources (version “zeromq-2.0.10”) and successfully builded it.
Next i started with installing zmq gem. I entered command:
‘gem install zmq -- --with-zmq-dir=D:\develop\projects\libs\zeromq-2.0.10’
I received a lot of errors in “mkmf.log”
Служебная программа обслуживания программ Microsoft (R), версия 10.00.30319.01 (C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены. cl -nologo -I. -ID:/develop/develop/ruby-1.9.2/include/ruby-1.9.1/i386-mswin32_100 -ID:/develop/develop/ruby-1.9.2/include/ruby-1.9.1/ruby/backward -ID:/develop/develop/ruby-1.9.2/include/ruby-1.9.1 -I. -MD -Zi -w -wd4996 -O2sy- -Zm600 -ID:\develop\projects\libs\zeromq-2.0.10/include -Forbzmq.obj -c -Tcrbzmq.c rbzmq.c rbzmq.c(125) : error C2143: синтаксическая ошибка: отсутствие ";" перед "тип" rbzmq.c(126) : error C2065: ctx: необъявленный идентификатор rbzmq.c(131) : error C2065: ctx: необъявленный идентификатор rbzmq.c(152) : error C2061: синтаксическая ошибка: идентификатор "context_close" rbzmq.c(152) : error C2059: синтаксическая ошибка: ; rbzmq.c(152) : error C2059: синтаксическая ошибка: тип
Built 2.0.10 with no issues. It only built the x86_64 version, not i386, which was fine with me, no use for the i386 version.
woot:zeromq-2.0.10 mcmunn$ sudo gem install zmq -- --with-zmq-dir=/usr/local
Password:
Building native extensions. This could take a while...
ERROR: Error installing zmq:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-zmq-dir=/usr/local
checking for zmq_init() in -lzmq... no
extconf.rb:25: Couldn't find zmq library. try setting --with-zmq-dir= to tell me where it is. (RuntimeError)
Library was fine, built a quick C client/server with no problems.
Tried to run it manually and got a similar error.
Checked the log:
bash-3.2# ruby extconf.rb --with-zmq-dir=/usr/local
checking for zmq_init() in -lzmq... no
extconf.rb:25: Couldn't find zmq library. try setting --with-zmq-dir= to tell me where it is. (RuntimeError)
bash-3.2# cat *log
have_library: checking for zmq_init() in -lzmq... -------------------- no
"gcc -o conftest -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L/usr/local/lib -L. -arch i386 -arch x86_64 -lruby -lzmq -lpthread -ldl "
conftest.c: In function ‘t’:
conftest.c:3: error: ‘zmq_init’ undeclared (first use in this function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
conftest.c: In function ‘t’:
conftest.c:3: error: ‘zmq_init’ undeclared (first use in this function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
lipo: can't figure out the architecture type of: /var/tmp//ccc3JRtV.out
checked program was:
/* begin /
1: /top/
2: int main() { return 0; }
3: int t() { void ((volatile p)()); p = (void (()()))zmq_init; return 0; }
/ end */
"gcc -o conftest -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L/usr/local/lib -L. -arch i386 -arch x86_64 -lruby -lzmq -lpthread -ldl "
ld: warning: in /usr/local/lib/libzmq.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"_zmq_init", referenced from:
_t in ccc6CqbX.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccYS6JqC.out (No such file or directory)
checked program was:
/* begin /
1: /top/
2: int main() { return 0; }
3: int t() { zmq_init(); return 0; }
/ end */
So I forced x86_64 and it built fine:
bash-3.2# env ARCHFLAGS="-arch x86_64" ruby extconf.rb --with-zmq-dir=/usr/local
checking for zmq_init() in -lzmq... yes
Cool, I found your zmq install...
creating Makefile
bash-3.2# id
uid=0(root) gid=0(wheel) groups=0(wheel),401(com.apple.access_screensharing),402(com.apple.sharepoint.group.1),204(_developer),100(_lpoperator),98(_lpadmin),80(admin),61(localaccounts),29(certusers),20(staff),12(everyone),9(procmod),8(procview),5(operator),4(tty),3(sys),2(kmem),1(daemon)
bash-3.2# make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -c rbzmq.c
cc -arch x86_64 -pipe -bundle -undefined dynamic_lookup -o zmq.bundle rbzmq.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L/usr/local/lib -L. -arch x86_64 -lruby -lzmq -lpthread -ldl
bash-3.2# make install
/usr/bin/install -c -m 0755 zmq.bundle /Library/Ruby/Site/1.8/universal-darwin10.0
I'm working on zeromq3 branch,
The parameter order seems to be wrong at zmq_msg_send and zmq_msg_recv.
The first parameter of zmq_msg_send and zmq_msg_recv should be the zmq_msg_t
https://github.com/zeromq/zeromq3-x/blob/master/src/zmq.cpp#L544
I'm using the development version of zmq (2.1.0), which may be the source of my troubles, but I had assumed a minor version change should cause no problems.
The zmq gem seemed to install just fine, but it doesn't work when I require it (ruby 1.8.7p249):
irb(main):001:0> require 'rubygems'; require 'zmq'
=> true
irb(main):002:0> require 'zmq'
LoadError: libzmq.so.1: cannot open shared object file: No such file or directory - /usr/lib/ruby/gems/1.8/gems/zmq-2.1.0.1/lib/zmq.so
from /usr/lib/ruby/gems/1.8/gems/zmq-2.1.0.1/lib/zmq.so
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from (irb):2
from /usr/local/lib/site_ruby/1.8/rubygems.rb:168
Also on ruby 1.9.2p0:
ruby-1.9.2-p0 > require 'rubygems'
=> true
ruby-1.9.2-p0 > require 'zmq'
LoadError: libzmq.so.1: cannot open shared object file: No such file or directory - /home/ehsanul/.rvm/gems/ruby-1.9.2-p0/gems/zmq-2.1.0.1/lib/zmq.so
from <internal:lib/rubygems/custom_require>:33:in `require'
from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from (irb):2
from /home/ehsanul/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
Installed zmq via homebrew.
Then tried to run:
$ sudo gem install zmq -- --with-zmq-dir=/usr/local
Building native extensions. This could take a while...
ERROR: Error installing zmq:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-zmq-dir=/usr/local
checking for zmq.h... yes
checking for zmq_init() in -lzmq... no
checking for zmq_init() in -lzmq... no
extconf.rb:36: Couldn't find zmq library. try setting --with-zmq-dir=<path> to tell me where it is. (RuntimeError)
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/zmq-2.1.4 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/zmq-2.1.4/gem_make.out
Any help?
Doing the following:
sub = ZMQ::Context.new(1).socket(ZMQ::SUB)
sub.connect('tcp://127.0.0.1:13001')
sub.setsockopt(ZMQ::SUBSCRIBE, '')
Sometimes works, but sometimes will not work. It seems to have to do with the garbage collector trying to clear the context.
I think the gem should attempt to prevent the context from being released when there are sockets using it.
Currently, libzmq must be installed separately from gem.
For the ease of the installation, the gem itself should contain the c library itself (like cool.io contains libev etc). Also we cannot use libzmq on the PaaS platform like Heroku.
I just installed the latest stable: Stable release 3.2 (release candidate 2)
(I did not realize it was a release candidate until much later).
With zeromq 3.2.1 I was unable to run a gem install zmq. I got this message
PROMPT> gem install zmq
Fetching: zmq-2.1.4.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing zmq:
ERROR: Failed to build gem native extension.
/Users/neoneye/.rvm/rubies/ruby-1.9.3-p286/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:
^
With zeromq 2.2.0 I had no problems running gem install zmq.
Your README looks very wrong on github (https://github.com/zeromq/rbzmq) since its syntax is rdoc, not markdown.
Rename README.md
to README.rdoc
Which of the c functions are required to implement polling?
I have used the java client library under jruby and need the equivalent functionality for 1.9.2.
I have forked this library and would initially want to add polling to my fork.
If you have any pointers on where to start they'd be welcome and perhaps an answer to: why was polling not included originally?
Ta,
Guy
Hi,
I made a simple zeromq test under ruby ( http://gist.github.com/513982 )
I run the client and the server in any order and they work fine but if i kill the server the client will remains stuck in Receiving state, What is the correct way of handling this case ?
When I use zmq as a server, I met error "Invalid argument":
irb(main):001:0> require 'ffi-rzmq'
=> true
irb(main):002:0> context = ZMQ::Context.new
=> #<ZMQ::Context:0x00000002483cd8 @io_threads=1, @context=#<FFI::Pointer address=0x0000000265d210>>
irb(main):003:0> publisher = context.socket ZMQ::PUB
=> #<ZMQ::Socket:0x000000024911a8 @receiver_klass=ZMQ::Message, @socket=#<FFI::Pointer address=0x000000027500f0>, @name="PUB", @int_cache=nil, @longlong_cache=nil, @more_parts_array=[], @option_lookup=[nil, 1, nil, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, nil, nil, nil, nil, nil, 0, 0]>
irb(main):004:0> status = publisher.bind("tcp://127.0.0.1:5555")
=> -1
I use strace to get more information, I found below information:
socket(PF_INET, 0x80001 /* SOCK_??? */, IPPROTO_TCP) = -1 EINVAL (Invalid argument)
But in another machine, the same information is:
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 17
Then I tried another simple ruby httpserver:
require 'socket'
server = TCPServer.new("127.0.0.1", 5555)
loop do
socket = server.accept
while socket.gets.chop.length > 0
end
socket.puts "HTTP/1.1 200 OK"
socket.puts "Content-type: text/html"
socket.puts ""
socket.puts ""
socket.puts ""
socket.puts "
It works, and the strace information is :
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 5
I have tried many ways to fix this problem, but un-useful.
I need help, thanks.
Looks like this project is dead now?
the way extconf.rb is written, installing the gem fails quite often, even though libzmq and headers are installed in well known places.
$ ruby extconf.rb
checking for zmq_init() in -lzmq... no
extconf.rb:25: Couldn't find zmq library. try setting --with-zmq-dir=<path> to tell me where it is. (RuntimeError)
$ locate zmq.h
/opt/local/include/zmq.h
/opt/local/include/zmq.hpp
/opt/local/var/macports/software/zmq/2.1.7_0+pgm/opt/local/include/zmq.h
/opt/local/var/macports/software/zmq/2.1.7_0+pgm/opt/local/include/zmq.hpp
Having to specify --with-zmq-dir is a nuisance, especially in combination with using bundler.
I'm going to submit a patch.
Hi,
I have a test code:
require 'rubygems'
require 'zmq'
context = ZMQ::Context.new
chan = ARGV[0]
user = ARGV[1]
pub = context.socket ZMQ::PUB
pub.setsockopt ZMQ::IDENTITY, "test1-test2"
pub.bind 'tcp://*:5555'
while true
pub.send "chan1 #{rand.to_s()}"
sleep(1.0)
end
$ ruby -v ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
When trying to run that I get
ruby: symbol lookup error: /home/vagrant/.rvm/gems/ruby-2.2.1/gems/zmq-2.1.4/lib/zmq.so: undefined symbol: rb_thread_blocking_region
when code reaches pub.send
Works fine on Ruby 2.1.5
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.