V Wrapper For ZMQ
vmq
attempts to maintain a similar API to libzmq. Typical usage is:
- Create a context via
vmq.new_context()
- Create a socket via
vmq.new_socket(ctx, vmq.SocketType.@pub)
- Either call
sock.bind("tcp://127.0.0.1:5555")
orsock.connect("inproc://test")
to bind or connect to some endpoint - Send on the socket via
sock.send([]byte)
- Receive from a socket via
sock.recv()
orsock.recv_buf([]byte)
Here's an example:
import vmq
fn main() {
ctx := vmq.new_context()
push := vmq.new_socket(ctx, vmq.SocketType.push)?
pull := vmq.new_socket(ctx, vmq.SocketType.pull)?
push.bind("inproc://test")?
pull.connect("inproc://test")?
push.send("hello!".bytes())?
msg := pull.recv()?
println(string(msg))
}