Skip to content

Instantly share code, notes, and snippets.

@amclain
Created March 14, 2014 05:01
Show Gist options
  • Save amclain/9542364 to your computer and use it in GitHub Desktop.
Save amclain/9542364 to your computer and use it in GitHub Desktop.
require '0mq'
@server_keys = ZMQ::Curve.keypair
@client_keys = ZMQ::Curve.keypair
@path = 'tcp://127.0.0.1:5050'
# @path = 'ipc://test.ipc'
@server = ZMQ::Socket.new ZMQ::PULL
@server.set_opt ZMQ::CURVE_SERVER, 1
@server.set_opt ZMQ::CURVE_SECRETKEY, @server_keys[:private]
@server.bind @path
@client = ZMQ::Socket.new ZMQ::PUSH
@client.set_opt ZMQ::CURVE_SERVERKEY, @server_keys[:public]
@client.set_opt ZMQ::CURVE_PUBLICKEY, @client_keys[:public]
@client.set_opt ZMQ::CURVE_SECRETKEY, @client_keys[:private]
@client.connect @path
@client.send_string 'test'
puts @server.recv_string
File.delete 'test.ipc' if File.exists? 'test.ipc'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment