Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Works like ZeroMQ. Feels like Ruby.
The 0mq gem is a Ruby wrapper for the ZeroMQ (libzmq) API. Built on ffi-rzmq-core, the bridge from Ruby to ZeroMQ’s C API, the 0mq gem conceals the interaction with FFI and exposes an interface that uses blocks, raises exceptions, and feels like the Ruby we love to use.
Supported ZeroMQ (libzmq) versions:
3.x
4.x
Supported Ruby versions:
MRI >= 1.9
Rubinius 2.x
File them as issues or pull requests on the 0mq github repository.
Joe McIlvain
Alex McLain
Requires the libzmq library.
PGM (multicast) requires compiling libzmq with ./configure --with-pgm
Curve cryptography requires compiling libzmq with libsodium.
require '0mq'
Sockets can be created by specifying the ZMQ socket type. Any errors will be raised as exceptions.
socket = ZMQ::Socket.new ZMQ::PULL
socket.connect 'tcp://127.0.0.1:10000'
address = 'tcp://127.0.0.1:10000'
push = ZMQ::Socket.new ZMQ::PUSH
push.bind address
pull = ZMQ::Socket.new ZMQ::PULL
pull.connect address
push.send_string 'test'
string = pull.recv_string
puts string
address = 'inproc://poll_example'
pull = ZMQ::Socket.new ZMQ::PULL
pull.bind address
# Push a message after a delay.
Thread.new do
push = ZMQ::Socket.new ZMQ::PUSH
push.connect address
sleep 3
push.send_string 'test'
end
# Check if pull has any data (it doesn't yet).
# (Non-blocking demonstration.)
result = ZMQ::Poll.poll_nonblock pull
puts "No data available yet." if result.empty?
# Do a blocking poll until the pull socket has data.
ZMQ::Poll.poll pull do |socket, event|
puts socket.recv_string
end
A proxy can be used to funnel multiple endpoints into a single connection. See: Pub-Sub Network with a Proxy
# ---------------- ---------------- ---------------- ----------------
# | Endpoint REQ | --> | Proxy ROUTER | --> | Proxy DEALER | --> | Endpoint REP |
# ---------------- ---------------- ---------------- ----------------
# Create sockets.
endpoint_req = ZMQ::Socket.new(ZMQ::REQ).tap { |s| s.bind 'inproc://proxy_in' }
proxy_router = ZMQ::Socket.new(ZMQ::ROUTER).tap { |s| s.connect 'inproc://proxy_in' }
proxy_dealer = ZMQ::Socket.new(ZMQ::DEALER).tap { |s| s.bind 'inproc://proxy_out' }
endpoint_rep = ZMQ::Socket.new(ZMQ::REP).tap { |s| s.connect 'inproc://proxy_out' }
# Create the proxy.
Thread.new { ZMQ::Proxy.proxy proxy_router, proxy_dealer }
# Send a message.
endpoint_req.send_string 'test'
puts endpoint_rep.recv_string
FAQs
Unknown package
We found that 0mq demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.