Use Vsock with Libzmq
22 days ago
- AF_VSOCK is a socket address family for communication between VMs and hypervisors, similar to TCP/UDP with stream and datagram.
- VSOCK is supported in Linux since 4.8, with reserved CIDs like VMADDR_CID_LOCAL (loopback) available since 5.6.
- Low-level bindings exist for Python, C, Golang, Rust, but no high-level abstraction until libzmq added VSOCK support.
- libzmq's VSOCK implementation (PR #4822) allows using AF_VSOCK across all languages with libzmq bindings, plus features like authentication (Curve), req/rep, pub/sub.
- A forked pyzmq (pyzmq-vsock) enables testing VSOCK on loopback (CID local) without a VM, using 'vsock://@:port' endpoints.
- Example demonstrates a simple REQ/REP hello world over VSOCK loopback, and a production-ready example with Curve authentication and asyncio.