OCaml bindings for ZeroMQ
  • C 60.6%
  • OCaml 38.1%
  • Makefile 1.3%
Find a file
2015-04-08 10:45:23 +02:00
.gitignore Use ocamlbuild. 2014-10-17 16:00:20 +02:00
_tags Use ocamlbuild. 2014-10-17 16:00:20 +02:00
libozmqw.clib Use ocamlbuild. 2014-10-17 16:00:20 +02:00
Makefile Make install fixed. 2015-02-03 12:36:25 +01:00
META META link options fixed. 2015-04-08 10:45:23 +02:00
myocamlbuild.ml Use ocamlbuild. 2014-10-17 16:00:20 +02:00
ozmq.mldylib Use ocamlbuild. 2014-10-17 16:00:20 +02:00
ozmq.mllib Use ocamlbuild. 2014-10-17 16:00:20 +02:00
README.md Make install revised to use ocamlfind. 2015-02-03 10:51:20 +01:00
tests.ml Added zmq_poll support. 2014-10-13 22:16:05 +02:00
zmq.ml Added zmq_poll support. 2014-10-13 22:16:05 +02:00
zmq.mli Added zmq_poll support. 2014-10-13 22:16:05 +02:00
zmq_ocaml_wrapper.c Added zmq_poll support. 2014-10-13 22:16:05 +02:00

OCaml bindings for ZeroMQ

Merge of :

Pre-requisites

License

GNU General Public License.

Install

$ make
$ make tests
$ make install  # using ocamlfind

Usage

#use "topfind";;
#require "ozmq";;

(* create a zmq context *)
let ctx = Zmq.ctx_new ();;

(* create sockets *)
let push = Zmq.socket ctx Zmq.PUSH;;
let pull = Zmq.socket ctx Zmq.PULL;;

(* bind and connect sockets *)
Zmq.bind push "inproc://foo";;
Zmq.connect pull "inproc://foo";;

(* send and receive messages *)
Zmq.send push "Hello world!";;
Zmq.receive pull;;

(* send and receive multi-parts messages *)
Zmq.send_multiparts push ["Hello"; "world"; "!"];;
Zmq.receive_multiparts pull;;

(* send and receive messages unless this would block  *)
assert (Zmq.send_nowait push "Hello world!");;
assert (Zmq.receive_nowait pull = Some "Hello world!");;
assert (Zmq.receive_nowait pull = None);;
assert (Zmq.send_multiparts_nowait push ["Hello"; "world"; "!"]);;
assert (Zmq.receive_multiparts_nowait pull = ["Hello"; "world"; "!"]);;
assert (Zmq.receive_multiparts_nowait pull = []);;

(* close sockets and term *)
Zmq.close push;;
Zmq.close pull;;

Zmq.ctx_destroy ctx;;