chuckremes / ffi-rzmq

FFI bindings for ZeroMQ so the library can be used under JRuby and other FFI-compliant ruby runtimes
242 stars 62 forks source link

ZMQ.select? #134

Closed camertron closed 1 year ago

camertron commented 1 year ago

Hey there! In the lazy pirate example for Ruby here, I encountered the following line of code:

ZMQ.select( [@socket], nil, nil, @timeout)

Unfortunately trying this in my own code throws an error: NoMethodError: private method `select' called for ZMQ:Module. After some investigation I was able to determine the select method in this case is actually Kernel#select, indicating that the ZMQ module doesn't define its own version.

According to the require statement at the top of the example, it's using this library (ffi-rzmq). Was this method removed at some point, or is the example just wrong?

Thanks!

chuckremes commented 1 year ago

Hmmm, I don't have an answer for you. The person who wrote that code is probably a better person to ask.

The ffi-rzmq-core project does all of the wrapping of C functions using FFI. I just looked at it again and confirmed that at no point do I add select to the ZMQ namespace. I don't know if that example code ever worked; I do not recall exposing select at any time.

There is a zmq_poll function that should be used for polling/selecting ZMQ sockets. You should look into that.

If you can get lazy pirate working again using the accepted API, I bet the project would love a pull request to update the documentation for Ruby.

Let me know if you have any other questions.

camertron commented 1 year ago

Ok thanks @chuckremes 😄