Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jordan-bonecutter/vmq
V Wrapper For ZMQ
https://github.com/jordan-bonecutter/vmq
networking v vlang zmq
Last synced: 3 months ago
JSON representation
V Wrapper For ZMQ
- Host: GitHub
- URL: https://github.com/jordan-bonecutter/vmq
- Owner: jordan-bonecutter
- Created: 2021-10-02T02:37:42.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-22T19:58:16.000Z (almost 2 years ago)
- Last Synced: 2024-05-03T08:32:27.251Z (6 months ago)
- Topics: networking, v, vlang, zmq
- Language: V
- Homepage:
- Size: 26.4 KB
- Stars: 17
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-v - vmq - V wrapper For [ZMQ](https://zeromq.org/) (aka ZeroMQ, ØMQ, 0MQ: a high-performance asynchronous messaging library). (Libraries / Networking)
README
# vmq
![Run Main](https://github.com/jordan-bonecutter/vmq/workflows/Run%20Main/badge.svg)V Wrapper For ZMQ
`vmq` attempts to maintain a similar API to libzmq. Typical usage is:
1. Create a context via `vmq.new_context()`
2. Create a socket via `vmq.new_socket(ctx, vmq.SocketType.@pub)`
3. Either call `sock.bind("tcp://127.0.0.1:5555")` or `sock.connect("inproc://test")` to bind or connect to some endpoint
4. Send on the socket via `sock.send([]byte)`
5. Receive from a socket via `sock.recv()` or `sock.recv_buf([]byte)`Here's an example:
```v
import vmqfn 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))
}
```