OMQ::FFI -- libzmq Backend for OMQ

CI Gem Version License: ISC Ruby

Use libzmq under the same OMQ socket API. Requires libzmq 4.x installed on the system.

require "omq"
require "omq/ffi"

push = OMQ::PUSH.new(backend: :ffi)
push.connect("tcp://127.0.0.1:5555")
push.send("hello from libzmq")

The FFI backend replaces the entire pure-Ruby ZMTP stack with libzmq. The socket API, options, and Async integration remain identical. A dedicated I/O thread per socket handles all libzmq operations (libzmq sockets are not thread-safe).

Interop

FFI and native (pure Ruby) backends are wire-compatible. You can mix them freely:

# native REP server
rep = OMQ::REP.bind("tcp://127.0.0.1:5555")

# FFI REQ client
req = OMQ::REQ.new(backend: :ffi)
req.connect("tcp://127.0.0.1:5555")

Requirements

  • Ruby >= 3.3
  • libzmq 4.x (libzmq5 / libzmq3-dev on Debian/Ubuntu)
  • omq >= 0.10