Code Monkey home page Code Monkey logo

ocaml-zmq's Introduction

OCaml bindings for ZMQ 4.x

Build Status

Dependencies

  • OPAM
  • OCaml >= 4.03.0
  • OCaml >= 4.04.1, Async >= v0.11.0 for zmq-async
  • Ocaml >= 5.0.0 for zmq-eio
  • Lwt >= 2.6.0 for zmq-lwt
  • libzmq (c lib) >= 4.x

Install

opam install zmq

Uninstall

opam remove zmq

Documentation

API documentation can be found here

Development

With OPAM you can create a local switch which will install all dependencies automatically.

opam switch create ./ 5.1.1
make

License

See LICENSE.md.

Thanks

To the guys from the #ocaml channel, gildor, thelema, kaustuv and many others, wagerlabs, little-arhat and the ocaml-uint authors.

ocaml-zmq's People

Contributors

andersfugmann avatar andrewray avatar c-cube avatar cgmv avatar cjen1 avatar comanderp avatar djellemah avatar florianlaws avatar frejsoya avatar gdsfh avatar hcarty avatar hongy20 avatar jamesjer avatar jj-issuu avatar joelreymont avatar leonidas-from-xiv avatar little-arhat avatar pdhborges avatar rgrinberg avatar rixed avatar roddyyaga avatar simonellefsen avatar slegrand45 avatar tautologico avatar whitequark avatar xclerc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ocaml-zmq's Issues

uint dependency

It seems that zmq relies on uint, however uint is not presented in depends.

However even with uint installed I'm getting an error during zmq compilation:

#=== ERROR while compiling zmq.4.0-8 ==========================================#
# command      ocaml setup.ml -build
# path         /home/freyr/.opam/main/.opam-switch/build/zmq.4.0-8
# exit-code    1
# env-file     /home/freyr/.opam/log/zmq-19148-d2d111.env
# output-file  /home/freyr/.opam/log/zmq-19148-d2d111.out
### output ###
# [...]
# File "_tags", line 125, characters 44-84:
# Warning: the tag "oasis_executable_threadedloopback_native" is not used in any flag or dependency declaration, so it will have no effect; it may be a typo. Otherwise you can use `mark_tag_used` in your myocamlbuild.ml to disable this warning.
# File "_tags", line 126, characters 23-63:
# Warning: the tag "oasis_executable_threadedloopback_native" is not used in any flag or dependency declaration, so it will have no effect; it may be a typo. Otherwise you can use `mark_tag_used` in your myocamlbuild.ml to disable this warning.
# /home/freyr/.opam/main/bin/ocamlfind ocamlc -g -ccopt -I/usr/local/include -ccopt -I. -ccopt -I -ccopt /home/freyr/.opam/main/lib/stdint -ccopt -Wall -ccopt -Wextra -ccopt -O2 -c src/caml_zmq_stubs.c
# + /home/freyr/.opam/main/bin/ocamlfind ocamlc -g -ccopt -I/usr/local/include -ccopt -I. -ccopt -I -ccopt /home/freyr/.opam/main/lib/stdint -ccopt -Wall -ccopt -Wextra -ccopt -O2 -c src/caml_zmq_stubs.c
# src/caml_zmq_stubs.c:37:10: fatal error: uint64.h: No such file or directory
#  #include <uint64.h>
#           ^~~~~~~~~~
# compilation terminated.
# Command exited with code 2.
# E: Failure("Command ''/home/freyr/.opam/main/bin/ocamlbuild' src/libZMQ_stubs.a src/dllZMQ_stubs.so src/ZMQ.cma src/ZMQ.cmxa src/ZMQ.a src/ZMQ.cmxs examples/hwserver.native examples/hwclient.native examples/wuserver.native examples/wuclient.native examples/wuproxy.native examples/taskvent.native examples/taskwork.native examples/tasksink.native -tag debug' terminated with error code 10")

what's wrong?

It seems that oasis should use ~/.opam/main/include/ocaml_stdint include path instead of ~/.opam/main/lib/stdint. Any idea how to fix that?

Zmq_test.test_proxy occasionally causes an exception

I got the following exception while running the test suite (5.0 release).

Thread 1 killed on uncaught exception Zmq.ZMQ_exception(2, "Context
was terminated")
Raised at file "zmq.ml", line 738, characters 2-11
Called from file "zmq.ml", line 552, characters 14-41
Called from file "zmq.ml", line 552, characters 14-41
Called from file "zmq_test.ml", line 141, characters 6-31
Called from file "thread.ml", line 39, characters 8-14

This is being raised by Zmq.Proxy.create. It only happens very rarely.

I wonder if there is some race condition between the OCaml thread and Zmq.Context.terminate. I am planning to try to see how repeatable I can make the error and see if a Thread.join before terminate makes any difference (or works at all!).

Centos 7.0, ZMQ 4.1.4

I am not sure it is wise to have variant types

I get this kind of errors:
[...] contains type variables that cannot be generalized
And even if I explicitely type my function:

let zmq_server_setup (host: string) (port: int):
  ZMQ.Context.t * ([> `Rep] ZMQ.Socket.t) = [...]

I cannot get completely rid of those errors.
Was it absolutely necessary to use variants to write the zmq bindings?

allow ocaml 4.03

seems like zmq and ocaml-zmq build fine on OCaml 4.03. Is it possible to relax the lower bound for these?

Fails to build with OCaml 4.13.1

File "zmq-deferred/src/socket.ml", line 58, characters 12-27:
58 |             Queue.pop queue |> ignore
                 ^^^^^^^^^^^^^^^
Error (warning 5 [ignored-partial-application]): this function application is partial,
maybe some arguments are missing.

`Zmq.Socket.get_curve_publickey` fails with EINVAL

Here is the stacktrace:

Unix.Unix_error(Unix.EINVAL, "zmq_getsockopt", "")
Raised by primitive operation at file "zmq/src/zmq.ml", line 455, characters 4-47

The reason is pretty simple: for the curve related option, libzmq uses the size of the return buffer to choose between returning the raw key (if the buffer length is 32 or the z85 encoded version if it's 40+1 (+1 for some reason). Have a look at do_getsockopt_curve_key in options.cpp.

I'm about to send a PR that sets the return buffer length explicitly to 41 so we get back nice z85 keys. Other approaches are of course possible, such as adding an option for the user to choose, but I think it's more convenient to have only one format everywhere (given conversion functions between the two formats are available anyway).

Compilation error

Hello,

I've tried to install ocaml-zmq from source.
oasis setup works fine, but make all does not works at all.

$ make all
ocaml setup.ml -all 

Configuration: 
ocamlfind: ........................................... /home/nox/.opam/4.02.1/bin/ocamlfind
ocamlc: .............................................. /home/nox/.opam/4.02.1/bin/ocamlc.opt
ocamlopt: ............................................ /home/nox/.opam/4.02.1/bin/ocamlopt.opt
ocamlbuild: .......................................... /home/nox/.opam/4.02.1/bin/ocamlbuild
Package name: ........................................ ZMQ
Package version: ..................................... 4.0
os_type: ............................................. Unix
system: .............................................. linux
architecture: ........................................ amd64
ccomp_type: .......................................... cc
ocaml_version: ....................................... 4.02.1
standard_library_default: ............................ /home/nox/.opam/4.02.1/lib/ocaml
standard_library: .................................... /home/nox/.opam/4.02.1/lib/ocaml
standard_runtime: .................................... /home/nox/.opam/4.02.1/bin/ocamlrun
bytecomp_c_compiler: ................................. gcc -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -fPIC
native_c_compiler: ................................... gcc -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
model: ............................................... default
ext_obj: ............................................. .o
ext_asm: ............................................. .s
ext_lib: ............................................. .a
ext_dll: ............................................. .so
default_executable_name: ............................. a.out
systhread_supported: ................................. true
Install architecture-independent files dir: .......... /usr/local
Install architecture-dependent files in dir: ......... $prefix
User executables: .................................... $exec_prefix/bin
System admin executables: ............................ $exec_prefix/sbin
Program executables: ................................. $exec_prefix/libexec
Read-only single-machine data: ....................... $prefix/etc
Modifiable architecture-independent data: ............ $prefix/com
Modifiable single-machine data: ...................... $prefix/var
Object code libraries: ............................... $exec_prefix/lib
Read-only arch-independent data root: ................ $prefix/share
Read-only architecture-independent data: ............. $datarootdir
Info documentation: .................................. $datarootdir/info
Locale-dependent data: ............................... $datarootdir/locale
Man documentation: ................................... $datarootdir/man
Documentation root: .................................. $datarootdir/doc/$pkg_name
HTML documentation: .................................. $docdir
DVI documentation: ................................... $docdir
PDF documentation: ................................... $docdir
PS documentation: .................................... $docdir
findlib_version: ..................................... 1.6.1
is_native: ........................................... true
suffix_program: ...................................... 
Remove a file.: ...................................... rm -f
Remove a directory.: ................................. rm -rf
Turn ocaml debug flag on: ............................ true
Turn ocaml profile flag on: .......................... false
Compiler support generation of .cmxs.: ............... true
OCamlbuild additional flags: ......................... 
Build examples: ...................................... true
Create documentations: ............................... true
Compile tests executable and library and run them: ... false
pkg_unix: ............................................ /home/nox/.opam/4.02.1/lib/ocaml
pkg_uint_uint64: ..................................... /home/nox/.opam/4.02.1/lib/uint
pkg_str: ............................................. /home/nox/.opam/4.02.1/lib/ocaml

Finished, 1 target (0 cached) in 00:00:00.
+ /home/nox/.opam/4.02.1/bin/ocamlfind ocamlc -ccopt -I/usr/local/include -ccopt -I -ccopt /home/nox/.opam/4.02.1/lib/uint -ccopt -Wall -ccopt -Wextra -ccopt -O2 -c src/caml_zmq_stubs.c
src/caml_zmq_stubs.c: In function 'caml_zmq_new':
src/caml_zmq_stubs.c:66:5: warning: implicit declaration of function 'zmq_ctx_new' [-Wimplicit-function-declaration]
     void *ctx = zmq_ctx_new();
     ^
src/caml_zmq_stubs.c:66:17: warning: initialization makes pointer from integer without a cast
     void *ctx = zmq_ctx_new();
                 ^
src/caml_zmq_stubs.c: In function 'caml_zmq_term':
src/caml_zmq_stubs.c:80:5: warning: implicit declaration of function 'zmq_ctx_term' [-Wimplicit-function-declaration]
     int result = zmq_ctx_term(CAML_ZMQ_Context_val(ctx));
     ^
src/caml_zmq_stubs.c: At top level:
src/caml_zmq_stubs.c:92:5: error: 'ZMQ_IO_THREADS' undeclared here (not in a function)
     ZMQ_IO_THREADS,
     ^
src/caml_zmq_stubs.c:93:5: error: 'ZMQ_MAX_SOCKETS' undeclared here (not in a function)
     ZMQ_MAX_SOCKETS,
     ^
src/caml_zmq_stubs.c:94:5: error: 'ZMQ_IPV6' undeclared here (not in a function)
     ZMQ_IPV6
     ^
src/caml_zmq_stubs.c: In function 'caml_zmq_ctx_set_int_option':
src/caml_zmq_stubs.c:100:5: warning: implicit declaration of function 'zmq_ctx_set' [-Wimplicit-function-declaration]
     int result = zmq_ctx_set(CAML_ZMQ_Context_val(socket),
     ^
src/caml_zmq_stubs.c: In function 'caml_zmq_ctx_get_int_option':
src/caml_zmq_stubs.c:114:5: warning: implicit declaration of function 'zmq_ctx_get' [-Wimplicit-function-declaration]
     int result = zmq_ctx_get(CAML_ZMQ_Context_val(socket),
     ^
src/caml_zmq_stubs.c: At top level:
src/caml_zmq_stubs.c:184:5: error: 'ZMQ_MAXMSGSIZE' undeclared here (not in a function)
     ZMQ_MAXMSGSIZE
     ^
src/caml_zmq_stubs.c:185:1: error: initializer element is not constant
 };
 ^
src/caml_zmq_stubs.c:185:1: error: (near initialization for 'native_int64_option_for[0]')
src/caml_zmq_stubs.c:204:5: error: 'ZMQ_LAST_ENDPOINT' undeclared here (not in a function)
     ZMQ_LAST_ENDPOINT,
     ^
src/caml_zmq_stubs.c:204:5: error: initializer element is not constant
src/caml_zmq_stubs.c:204:5: error: (near initialization for 'native_bytes_option_for[3]')
src/caml_zmq_stubs.c:205:5: error: 'ZMQ_TCP_ACCEPT_FILTER' undeclared here (not in a function)
     ZMQ_TCP_ACCEPT_FILTER,
     ^
src/caml_zmq_stubs.c:205:5: error: initializer element is not constant
src/caml_zmq_stubs.c:205:5: error: (near initialization for 'native_bytes_option_for[4]')
src/caml_zmq_stubs.c:206:5: error: 'ZMQ_PLAIN_USERNAME' undeclared here (not in a function)
     ZMQ_PLAIN_USERNAME,
     ^
src/caml_zmq_stubs.c:206:5: error: initializer element is not constant
src/caml_zmq_stubs.c:206:5: error: (near initialization for 'native_bytes_option_for[5]')
src/caml_zmq_stubs.c:207:5: error: 'ZMQ_PLAIN_PASSWORD' undeclared here (not in a function)
     ZMQ_PLAIN_PASSWORD,
     ^
src/caml_zmq_stubs.c:207:5: error: initializer element is not constant
src/caml_zmq_stubs.c:207:5: error: (near initialization for 'native_bytes_option_for[6]')
src/caml_zmq_stubs.c:208:5: error: 'ZMQ_CURVE_PUBLICKEY' undeclared here (not in a function)
     ZMQ_CURVE_PUBLICKEY,
     ^
src/caml_zmq_stubs.c:208:5: error: initializer element is not constant
src/caml_zmq_stubs.c:208:5: error: (near initialization for 'native_bytes_option_for[7]')
src/caml_zmq_stubs.c:209:5: error: 'ZMQ_CURVE_SECRETKEY' undeclared here (not in a function)
     ZMQ_CURVE_SECRETKEY,
     ^
src/caml_zmq_stubs.c:209:5: error: initializer element is not constant
src/caml_zmq_stubs.c:209:5: error: (near initialization for 'native_bytes_option_for[8]')
src/caml_zmq_stubs.c:210:5: error: 'ZMQ_CURVE_SERVERKEY' undeclared here (not in a function)
     ZMQ_CURVE_SERVERKEY,
     ^
src/caml_zmq_stubs.c:210:5: error: initializer element is not constant
src/caml_zmq_stubs.c:210:5: error: (near initialization for 'native_bytes_option_for[9]')
src/caml_zmq_stubs.c:211:5: error: 'ZMQ_ZAP_DOMAIN' undeclared here (not in a function)
     ZMQ_ZAP_DOMAIN,
     ^
src/caml_zmq_stubs.c:211:5: error: initializer element is not constant
src/caml_zmq_stubs.c:211:5: error: (near initialization for 'native_bytes_option_for[10]')
src/caml_zmq_stubs.c:240:5: error: 'ZMQ_SNDHWM' undeclared here (not in a function)
     ZMQ_SNDHWM,
     ^
src/caml_zmq_stubs.c:240:5: error: initializer element is not constant
src/caml_zmq_stubs.c:240:5: error: (near initialization for 'native_int_option_for[11]')
src/caml_zmq_stubs.c:241:5: error: 'ZMQ_RCVHWM' undeclared here (not in a function)
     ZMQ_RCVHWM,
     ^
src/caml_zmq_stubs.c:241:5: error: initializer element is not constant
src/caml_zmq_stubs.c:241:5: error: (near initialization for 'native_int_option_for[12]')
src/caml_zmq_stubs.c:242:5: error: 'ZMQ_MULTICAST_HOPS' undeclared here (not in a function)
     ZMQ_MULTICAST_HOPS,
     ^
src/caml_zmq_stubs.c:242:5: error: initializer element is not constant
src/caml_zmq_stubs.c:242:5: error: (near initialization for 'native_int_option_for[13]')
src/caml_zmq_stubs.c:245:5: error: initializer element is not constant
     ZMQ_IPV6,
     ^
src/caml_zmq_stubs.c:245:5: error: (near initialization for 'native_int_option_for[16]')
src/caml_zmq_stubs.c:246:5: error: 'ZMQ_ROUTER_MANDATORY' undeclared here (not in a function)
     ZMQ_ROUTER_MANDATORY,
     ^
src/caml_zmq_stubs.c:246:5: error: initializer element is not constant
src/caml_zmq_stubs.c:246:5: error: (near initialization for 'native_int_option_for[17]')
src/caml_zmq_stubs.c:247:5: error: 'ZMQ_TCP_KEEPALIVE' undeclared here (not in a function)
     ZMQ_TCP_KEEPALIVE,
     ^
src/caml_zmq_stubs.c:247:5: error: initializer element is not constant
src/caml_zmq_stubs.c:247:5: error: (near initialization for 'native_int_option_for[18]')
src/caml_zmq_stubs.c:248:5: error: 'ZMQ_TCP_KEEPALIVE_CNT' undeclared here (not in a function)
     ZMQ_TCP_KEEPALIVE_CNT,
     ^
src/caml_zmq_stubs.c:248:5: error: initializer element is not constant
src/caml_zmq_stubs.c:248:5: error: (near initialization for 'native_int_option_for[19]')
src/caml_zmq_stubs.c:249:5: error: 'ZMQ_TCP_KEEPALIVE_IDLE' undeclared here (not in a function)
     ZMQ_TCP_KEEPALIVE_IDLE,
     ^
src/caml_zmq_stubs.c:249:5: error: initializer element is not constant
src/caml_zmq_stubs.c:249:5: error: (near initialization for 'native_int_option_for[20]')
src/caml_zmq_stubs.c:250:5: error: 'ZMQ_TCP_KEEPALIVE_INTVL' undeclared here (not in a function)
     ZMQ_TCP_KEEPALIVE_INTVL,
     ^
src/caml_zmq_stubs.c:250:5: error: initializer element is not constant
src/caml_zmq_stubs.c:250:5: error: (near initialization for 'native_int_option_for[21]')
src/caml_zmq_stubs.c:251:5: error: 'ZMQ_IMMEDIATE' undeclared here (not in a function)
     ZMQ_IMMEDIATE,
     ^
src/caml_zmq_stubs.c:251:5: error: initializer element is not constant
src/caml_zmq_stubs.c:251:5: error: (near initialization for 'native_int_option_for[22]')
src/caml_zmq_stubs.c:252:5: error: 'ZMQ_XPUB_VERBOSE' undeclared here (not in a function)
     ZMQ_XPUB_VERBOSE,
     ^
src/caml_zmq_stubs.c:252:5: error: initializer element is not constant
src/caml_zmq_stubs.c:252:5: error: (near initialization for 'native_int_option_for[23]')
src/caml_zmq_stubs.c:253:5: error: 'ZMQ_MECHANISM' undeclared here (not in a function)
     ZMQ_MECHANISM,
     ^
src/caml_zmq_stubs.c:253:5: error: initializer element is not constant
src/caml_zmq_stubs.c:253:5: error: (near initialization for 'native_int_option_for[24]')
src/caml_zmq_stubs.c:254:5: error: 'ZMQ_PLAIN_SERVER' undeclared here (not in a function)
     ZMQ_PLAIN_SERVER,
     ^
src/caml_zmq_stubs.c:254:5: error: initializer element is not constant
src/caml_zmq_stubs.c:254:5: error: (near initialization for 'native_int_option_for[25]')
src/caml_zmq_stubs.c:255:5: error: 'ZMQ_CURVE_SERVER' undeclared here (not in a function)
     ZMQ_CURVE_SERVER,
     ^
src/caml_zmq_stubs.c:255:5: error: initializer element is not constant
src/caml_zmq_stubs.c:255:5: error: (near initialization for 'native_int_option_for[26]')
src/caml_zmq_stubs.c:256:5: error: 'ZMQ_PROBE_ROUTER' undeclared here (not in a function)
     ZMQ_PROBE_ROUTER,
     ^
src/caml_zmq_stubs.c:256:5: error: initializer element is not constant
src/caml_zmq_stubs.c:256:5: error: (near initialization for 'native_int_option_for[27]')
src/caml_zmq_stubs.c:257:5: error: 'ZMQ_REQ_CORRELATE' undeclared here (not in a function)
     ZMQ_REQ_CORRELATE,
     ^
src/caml_zmq_stubs.c:257:5: error: initializer element is not constant
src/caml_zmq_stubs.c:257:5: error: (near initialization for 'native_int_option_for[28]')
src/caml_zmq_stubs.c:258:5: error: 'ZMQ_REQ_RELAXED' undeclared here (not in a function)
     ZMQ_REQ_RELAXED,
     ^
src/caml_zmq_stubs.c:258:5: error: initializer element is not constant
src/caml_zmq_stubs.c:258:5: error: (near initialization for 'native_int_option_for[29]')
src/caml_zmq_stubs.c:259:5: error: 'ZMQ_CONFLATE' undeclared here (not in a function)
     ZMQ_CONFLATE,
     ^
src/caml_zmq_stubs.c:259:5: error: initializer element is not constant
src/caml_zmq_stubs.c:259:5: error: (near initialization for 'native_int_option_for[30]')
src/caml_zmq_stubs.c: In function 'caml_zmq_disconnect':
src/caml_zmq_stubs.c:380:5: warning: implicit declaration of function 'zmq_disconnect' [-Wimplicit-function-declaration]
     int result = zmq_disconnect(CAML_ZMQ_Socket_val(socket), String_val(string_address));
     ^
src/caml_zmq_stubs.c: In function 'caml_zmq_unbind':
src/caml_zmq_stubs.c:400:5: warning: implicit declaration of function 'zmq_unbind' [-Wimplicit-function-declaration]
     int result = zmq_unbind(CAML_ZMQ_Socket_val(socket), String_val(string_address));
     ^
src/caml_zmq_stubs.c: In function 'caml_zmq_send':
src/caml_zmq_stubs.c:426:5: warning: implicit declaration of function 'zmq_msg_send' [-Wimplicit-function-declaration]
     result = zmq_msg_send(&msg, sock, option);
     ^
src/caml_zmq_stubs.c: In function 'caml_zmq_recv':
src/caml_zmq_stubs.c:458:5: warning: implicit declaration of function 'zmq_msg_recv' [-Wimplicit-function-declaration]
     result = zmq_msg_recv(&msg, sock, option);
     ^
src/caml_zmq_stubs.c: In function 'caml_zmq_proxy2':
src/caml_zmq_stubs.c:487:5: warning: implicit declaration of function 'zmq_proxy' [-Wimplicit-function-declaration]
     int result = zmq_proxy(native_frontend, native_backend, NULL);
     ^
src/caml_zmq_stubs.c: In function 'caml_zmq_socket_monitor':
src/caml_zmq_stubs.c:513:5: warning: implicit declaration of function 'zmq_socket_monitor' [-Wimplicit-function-declaration]
     int result = zmq_socket_monitor(CAML_ZMQ_Socket_val(socket), String_val(address), ZMQ_EVENT_ALL);
     ^
src/caml_zmq_stubs.c:513:87: error: 'ZMQ_EVENT_ALL' undeclared (first use in this function)
     int result = zmq_socket_monitor(CAML_ZMQ_Socket_val(socket), String_val(address), ZMQ_EVENT_ALL);
                                                                                       ^
src/caml_zmq_stubs.c:513:87: note: each undeclared identifier is reported only once for each function it appears in
src/caml_zmq_stubs.c: In function 'caml_decode_monitor_event':
src/caml_zmq_stubs.c:543:10: error: 'ZMQ_EVENT_CONNECTED' undeclared (first use in this function)
     case ZMQ_EVENT_CONNECTED:
          ^
src/caml_zmq_stubs.c:549:10: error: 'ZMQ_EVENT_CONNECT_DELAYED' undeclared (first use in this function)
     case ZMQ_EVENT_CONNECT_DELAYED:
          ^
src/caml_zmq_stubs.c:554:10: error: 'ZMQ_EVENT_CONNECT_RETRIED' undeclared (first use in this function)
     case ZMQ_EVENT_CONNECT_RETRIED:
          ^
src/caml_zmq_stubs.c:560:10: error: 'ZMQ_EVENT_LISTENING' undeclared (first use in this function)
     case ZMQ_EVENT_LISTENING:
          ^
src/caml_zmq_stubs.c:566:10: error: 'ZMQ_EVENT_BIND_FAILED' undeclared (first use in this function)
     case ZMQ_EVENT_BIND_FAILED:
          ^
src/caml_zmq_stubs.c:573:10: error: 'ZMQ_EVENT_ACCEPTED' undeclared (first use in this function)
     case ZMQ_EVENT_ACCEPTED:
          ^
src/caml_zmq_stubs.c:579:10: error: 'ZMQ_EVENT_ACCEPT_FAILED' undeclared (first use in this function)
     case ZMQ_EVENT_ACCEPT_FAILED:
          ^
src/caml_zmq_stubs.c:586:10: error: 'ZMQ_EVENT_CLOSED' undeclared (first use in this function)
     case ZMQ_EVENT_CLOSED:
          ^
src/caml_zmq_stubs.c:592:10: error: 'ZMQ_EVENT_CLOSE_FAILED' undeclared (first use in this function)
     case ZMQ_EVENT_CLOSE_FAILED:
          ^
src/caml_zmq_stubs.c:598:10: error: 'ZMQ_EVENT_DISCONNECTED' undeclared (first use in this function)
     case ZMQ_EVENT_DISCONNECTED:
          ^
src/caml_zmq_stubs.c: In function 'caml_z85_encode':
src/caml_zmq_stubs.c:630:5: warning: implicit declaration of function 'zmq_z85_encode' [-Wimplicit-function-declaration]
     if (zmq_z85_encode(String_val(result), (uint8_t*) String_val(source), length) == NULL)
     ^
src/caml_zmq_stubs.c:630:83: warning: comparison between pointer and integer
     if (zmq_z85_encode(String_val(result), (uint8_t*) String_val(source), length) == NULL)
                                                                                   ^
src/caml_zmq_stubs.c: In function 'caml_z85_decode':
src/caml_zmq_stubs.c:641:5: warning: implicit declaration of function 'zmq_z85_decode' [-Wimplicit-function-declaration]
     if (zmq_z85_decode((uint8_t*) String_val(result), String_val(source)) == NULL)
     ^
src/caml_zmq_stubs.c:641:75: warning: comparison between pointer and integer
     if (zmq_z85_decode((uint8_t*) String_val(result), String_val(source)) == NULL)
                                                                           ^
src/caml_zmq_stubs.c: In function 'caml_curve_keypair':
src/caml_zmq_stubs.c:658:5: warning: implicit declaration of function 'zmq_curve_keypair' [-Wimplicit-function-declaration]
     int result = zmq_curve_keypair(String_val(public), String_val(secret));
     ^
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
E: Failure("Command ''/home/nox/.opam/4.02.1/bin/ocamlbuild' src/libZMQ_stubs.a src/dllZMQ_stubs.so src/ZMQ.cma src/ZMQ.cmxa src/ZMQ.a src/ZMQ.cmxs examples/hwserver.native examples/hwclient.native examples/wuserver.native examples/wuclient.native examples/wuproxy.native examples/taskvent.native examples/taskwork.native examples/tasksink.native -tag debug' terminated with error code 10")
Makefile:16: recipe for target 'all' failed
make: *** [all] Error 1

It does not works either with opam install

$ opam install zmq
The following actions will be performed:
  - install conf-zmq 0.1                                [required by zmq]
  - install zmq      4.0-5
===== 2 to install =====
Do you want to continue ? [Y/n] y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[zmq] Archive in cache

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-> installed conf-zmq.0.1
[ERROR] The compilation of zmq failed at "ocaml setup.ml -build".
Processing  2/2: [zmq: ocamlfind remove]
#=== ERROR while installing zmq.4.0-5 =========================================#
# opam-version 1.2.2
# os           linux
# command      ocaml setup.ml -build
# path         /home/nox/.opam/4.02.1/build/zmq.4.0-5
# compiler     4.02.1
# exit-code    1
# env-file     /home/nox/.opam/4.02.1/build/zmq.4.0-5/zmq-1330-d2c37b.env
# stdout-file  /home/nox/.opam/4.02.1/build/zmq.4.0-5/zmq-1330-d2c37b.out
# stderr-file  /home/nox/.opam/4.02.1/build/zmq.4.0-5/zmq-1330-d2c37b.err
### stdout ###
# src/caml_zmq_stubs.c:641:5: warning: implicit declaration of function 'zmq_z85_decode' [-Wimplicit-function-declaration]
# [...]
#      ^
# src/caml_zmq_stubs.c:641:75: warning: comparison between pointer and integer
#      if (zmq_z85_decode((uint8_t*) String_val(result), String_val(source)) == NULL)
#                                                                            ^
# src/caml_zmq_stubs.c: In function 'caml_curve_keypair':
# src/caml_zmq_stubs.c:658:5: warning: implicit declaration of function 'zmq_curve_keypair' [-Wimplicit-function-declaration]
#      int result = zmq_curve_keypair(String_val(public), String_val(secret));
#      ^
# Command exited with code 2.
### stderr ###
# E: Failure("Command ''/home/nox/.opam/4.02.1/bin/ocamlbuild' src/libZMQ_stubs.a src/dllZMQ_stubs.so src/ZMQ.cma src/ZMQ.cmxa src/ZMQ.a src/ZMQ.cmxs examples/hwserver.native examples/hwclient.native examples/wuserver.native examples/wuclient.native examples/wuproxy.native examples/taskvent.native examples/taskwork.native examples/tasksink.native -tag debug' terminated with error code 10")



=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions failed
  - install zmq 4.0-5
The following changes have been performed
  - install conf-zmq 0.1

The former state can be restored with:
    opam switch import "~/.opam/4.02.1/backup/state-20160408101920.export"

Do you have any idea of what is wrong ?
Did I miss something ?

Regards,
Arnaud

Error while building with OCaml 5.0

I get the following error while running opam install zmq with ocaml 5.0.0+trunk:

The following actions will be performed:
  ∗ install zmq 5.1.5

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved zmq.5.1.5  (cached)
[ERROR] The compilation of zmq.5.1.5 failed at "dune build -p zmq -j 7 @install".

#=== ERROR while compiling zmq.5.1.5 ==========================================#
# context     2.1.0 | linux/x86_64 | ocaml-variants.5.0.0+trunk | https://opam.ocaml.org#a6d8661d
# path        ~/.opam/5.0.0+trunk/.opam-switch/build/zmq.5.1.5
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p zmq -j 7 @install
# exit-code   1
# env-file    ~/.opam/log/zmq-201580-b9972a.env
# output-file ~/.opam/log/zmq-201580-b9972a.out
### output ###
# File "zmq/src/dune", line 15, characters 24-32:
# 15 |  (libraries unix stdint bigarray))
#                              ^^^^^^^^
# Error: Library "bigarray" not found.
# -> required by library "zmq" in _build/default/zmq/src
# -> required by _build/default/META.zmq
# -> required by _build/install/default/lib/zmq/META
# -> required by _build/default/zmq.install
# -> required by alias install



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build zmq 5.1.5
└─ 
╶─ No changes have been performed

I think that this error is happening because the bigarray library was removed and it is now part of the standard library.

Release 5.0.0

We should make a new release soon with all the changes going in.
For that we need to decide what needs to go in (e.g. Should we wait for zmq-lwt?)
This ticket if for coordinating the release (when, what and who makes the PR against opam-repository).

Also I think we should have a Changelog file to list changes between releases, and we might need to consider a better version scheme.

Allow people to use bigarrays instead of string

Hi,

It would be nice if the send and receive functions could use a bigarray instead of a string.
That would allow less data copying.
The new send would then take a bigarray, an int offset and an int length as parameters.
Receive would take a bigarray, an int offset and a max length as parameters.

Build issue while Cross-Compiling

Hi
I'm actually trying to cross-compile the ocaml-zmq, but I'm facing an issue as the system cannot find the correct zmq headers and c library
It appears that your ocamlbuild.ml has some hard paths (-I/usr/local/include"; and "-L/usr/local/lib")

Could you replace them by optional paths as suggested in following patch
Cheers
Erwan

--- myocamlbuild.ml	2017-11-07 07:37:46.818678563 +0100
+++ myocamlbuild.ml.new	2017-11-07 07:46:45.032930432 +0100
@@ -880,6 +880,17 @@
 
 # 881 "myocamlbuild.ml"
 open Ocamlbuild_plugin;;
+
+let mycflags =
+    try
+      "-I"^Sys.getenv "ZMQ_INCLUDE_PATH"
+    with _ -> "-I/usr/local/include"
+
+let myclibs =
+    try
+      "-L"^Sys.getenv "ZMQ_LIBRARY_PATH"
+    with _ -> "-L/usr/local/lib "
+
 let package_default =
   {
      MyOCamlbuildBase.lib_ocaml = [("ZMQ", ["src"], [])];
@@ -897,7 +908,7 @@
                  S
                    [
                       A "-ccopt";
-                      A "-I/usr/local/include";
+                      A mycflags;
                       A "-ccopt";
                       A "-I.";
                       A "-ccopt";
@@ -915,10 +926,10 @@
           (["oasis_library_zmq_cclib"; "link"],
             [
                (OASISExpr.EBool true,
-                 S [A "-cclib"; A "-L/usr/local/lib"; A "-cclib"; A "-lzmq"])
+                 S [A "-cclib"; A myclibs; A "-cclib"; A "-lzmq"])
             ]);
           (["oasis_library_zmq_cclib"; "ocamlmklib"; "c"],
-            [(OASISExpr.EBool true, S [A "-L/usr/local/lib"; A "-lzmq"])]);
+            [(OASISExpr.EBool true, S [A myclibs; A "-lzmq"])]);
           (["oasis_executable_test_byte"; "ocaml"; "link"; "byte"],
             [(OASISExpr.EBool true, S [A "-thread"])]);
           (["oasis_executable_test_native"; "ocaml"; "link"; "native"],

Generate documentation

It would be good to automatically generate API documentation on https://issuu.github.io/ocaml-zmq. I am not sure what the best way for doing so is now in 2018, so I'd very much appreciate input on what to check out. The best way would be if it could be somehow automatically split into master vs release tags.

My main priority would be that it can be somehow automated so it is not easy to forget.

the opam package doesn't install

# ocaml --version
The OCaml toplevel, version 4.06.1
# opam --version
2.0.1
# opam install -v ocaml-zmq
The following actions will be performed:
  ∗ install ocaml-zmq 0

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ocaml-zmq.0] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+ /home/berenger/.opam/opam-init/hooks/sandbox.sh "build" "ocaml" "setup.ml" "-configure" "--prefix" "/home/berenger/.opam/4.06.1" (CWD=/home/berenger/.opam/4.06.1/.opam-switch/build/ocaml-zmq.0)
- File "/home/hcarty/ocamlbrew/ocaml-4.00.0/build/odb/install-oasis/oasis-0.3.0/src/oasis/OASISString.ml", line 118, characters 8-26:
- Warning 3: deprecated: String.set
- Use Bytes.set instead.
- File "/home/hcarty/ocamlbrew/ocaml-4.00.0/build/odb/install-oasis/oasis-0.3.0/src/oasis/OASISString.ml", line 118, characters 8-11:
- Error: This expression has type string but an expression was expected of type
-          bytes
[ERROR] The compilation of ocaml-zmq failed at
        "/home/berenger/.opam/opam-init/hooks/sandbox.sh build ocaml setup.ml
        -configure --prefix /home/berenger/.opam/4.06.1".

#=== ERROR while compiling ocaml-zmq.0 ========================================#
# context     2.0.1 | linux/x86_64 | ocaml-base-compiler.4.06.1 | git+https://github.com/ocaml/opam-repository.git
# path        ~/.opam/4.06.1/.opam-switch/build/ocaml-zmq.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build ocaml setup.ml -configure --prefix /home/berenger/.opam/4.06.1
# exit-code   2
# env-file    ~/.opam/log/ocaml-zmq-4673-05296d.env
# output-file ~/.opam/log/ocaml-zmq-4673-05296d.out
### output ###
# File "/home/hcarty/ocamlbrew/ocaml-4.00.0/build/odb/install-oasis/oasis-0.3.0/src/oasis/OASISString.ml", line 118, characters 8-26:
# Warning 3: deprecated: String.set
# Use Bytes.set instead.
# File "/home/hcarty/ocamlbrew/ocaml-4.00.0/build/odb/install-oasis/oasis-0.3.0/src/oasis/OASISString.ml", line 118, characters 8-11:
# Error: This expression has type string but an expression was expected of type
#          bytes



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-zmq 0
└─ 
╶─ No changes have been performed

The packages you requested declare the following system dependencies. Please
make sure they are installed before retrying:
    libzmq3-dev

'opam install -v ocaml-zmq' failed.

4.05 support

On a clean 4.05.0+beta1 opam switch, trying to install zmq.3.2-2 I'm getting the error log below. On 4.04 it works fine, so I will assume it isn't a problem with my environment.

/home/copy/.opam/4.05.0+beta1+flambda/bin/ocamlopt.opt unix.cmxa -I /home/copy/.opam/4.05.0+beta1+flambda/lib/ocamlbuild /home/copy/.opam/4.05.0+beta1+flambda/lib/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /home/copy/.opam/4.05.0+beta1+flambda/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
/home/copy/.opam/4.05.0+beta1+flambda/bin/ocamlfind ocamlc -g -ccopt -Wall -ccopt -W -ccopt -Wextra -ccopt -O2 -c src/caml_zmq_stubs.c
+ /home/copy/.opam/4.05.0+beta1+flambda/bin/ocamlfind ocamlc -g -ccopt -Wall -ccopt -W -ccopt -Wextra -ccopt -O2 -c src/caml_zmq_stubs.c
In file included from src/caml_zmq_stubs.c:37:0:
src/uint64.h:15:29: error: unknown type name ‘uint64’
 value caml_uint_copy_uint64(uint64 i);
                             ^~~~~~
src/caml_zmq_stubs.c: In function ‘caml_zmq_set_uint64_option’:
src/caml_zmq_stubs.c:137:5: error: unknown type name ‘uint64’
     uint64 val = CAML_UINT_Uint64_val(socket_option);
     ^~~~~~
In file included from src/caml_zmq_stubs.c:37:0:
src/uint64.h:13:37: error: ‘uint64’ undeclared (first use in this function)
 #define CAML_UINT_Uint64_val(v) (*((uint64 *)Data_custom_val(v)))
                                     ^
src/caml_zmq_stubs.c:137:18: note: in expansion of macro ‘CAML_UINT_Uint64_val’
     uint64 val = CAML_UINT_Uint64_val(socket_option);
                  ^~~~~~~~~~~~~~~~~~~~
src/uint64.h:13:37: note: each undeclared identifier is reported only once for each function it appears in
 #define CAML_UINT_Uint64_val(v) (*((uint64 *)Data_custom_val(v)))
                                     ^
src/caml_zmq_stubs.c:137:18: note: in expansion of macro ‘CAML_UINT_Uint64_val’
     uint64 val = CAML_UINT_Uint64_val(socket_option);
                  ^~~~~~~~~~~~~~~~~~~~
src/uint64.h:13:45: error: expected expression before ‘)’ token
 #define CAML_UINT_Uint64_val(v) (*((uint64 *)Data_custom_val(v)))
                                             ^
src/caml_zmq_stubs.c:137:18: note: in expansion of macro ‘CAML_UINT_Uint64_val’
     uint64 val = CAML_UINT_Uint64_val(socket_option);
                  ^~~~~~~~~~~~~~~~~~~~
src/caml_zmq_stubs.c: In function ‘caml_zmq_set_int64_option’:
src/caml_zmq_stubs.c:154:5: error: unknown type name ‘int64’
     int64 val = Int64_val(Field(socket_option, 1));
     ^~~~~
src/caml_zmq_stubs.c: In function ‘caml_zmq_get_uint64_option’:
src/caml_zmq_stubs.c:237:5: error: unknown type name ‘uint64’
     uint64 mark;
     ^~~~~~
In file included from src/caml_zmq_stubs.c:15:0:
src/caml_zmq_stubs.c:244:17: warning: implicit declaration of function ‘caml_uint_copy_uint64’ [-Wimplicit-function-declaration]
     CAMLreturn (caml_uint_copy_uint64(mark));
                 ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:340:29: note: in definition of macro ‘CAMLreturnT’
   type caml__temp_result = (result); \
                             ^~~~~~
src/caml_zmq_stubs.c:244:5: note: in expansion of macro ‘CAMLreturn’
     CAMLreturn (caml_uint_copy_uint64(mark));
     ^~~~~~~~~~
src/caml_zmq_stubs.c: In function ‘caml_zmq_get_int64_option’:
src/caml_zmq_stubs.c:249:5: error: unknown type name ‘int64’
     int64 mark;
     ^~~~~
src/caml_zmq_stubs.c: In function ‘caml_zmq_event_recv’:
src/caml_zmq_stubs.c:496:5: error: unknown type name ‘zmq_event_t’
     zmq_event_t event;
     ^~~~~~~~~~~
src/caml_zmq_stubs.c:499:18: error: request for member ‘event’ in something not a structure or union
     switch (event.event) {
                  ^
In file included from src/caml_zmq_stubs.c:15:0:
src/caml_zmq_stubs.c:502:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.connected.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:503:44: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_fd(event.data.connected.fd));
                                            ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:27:21: note: in expansion of macro ‘Val_int’
 #  define Val_fd(x) Val_int(x)
                     ^~~~~~~
src/caml_zmq_stubs.c:503:32: note: in expansion of macro ‘Val_fd’
         Store_field(result, 1, Val_fd(event.data.connected.fd));
                                ^~~~~~
src/caml_zmq_stubs.c:507:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.connect_delayed.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:508:45: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_int(event.data.connect_delayed.err));
                                             ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:508:32: note: in expansion of macro ‘Val_int’
         Store_field(result, 1, Val_int(event.data.connect_delayed.err));
                                ^~~~~~~
src/caml_zmq_stubs.c:509:67: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 2, caml_copy_string(zmq_strerror(event.data.connect_delayed.err)));
                                                                   ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:514:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.connect_retried.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:515:45: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_int(event.data.connect_retried.interval));
                                             ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:515:32: note: in expansion of macro ‘Val_int’
         Store_field(result, 1, Val_int(event.data.connect_retried.interval));
                                ^~~~~~~
src/caml_zmq_stubs.c:520:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.listening.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:521:44: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_fd(event.data.listening.fd));
                                            ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:27:21: note: in expansion of macro ‘Val_int’
 #  define Val_fd(x) Val_int(x)
                     ^~~~~~~
src/caml_zmq_stubs.c:521:32: note: in expansion of macro ‘Val_fd’
         Store_field(result, 1, Val_fd(event.data.listening.fd));
                                ^~~~~~
src/caml_zmq_stubs.c:526:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.bind_failed.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:527:45: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_int(event.data.bind_failed.err));
                                             ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:527:32: note: in expansion of macro ‘Val_int’
         Store_field(result, 1, Val_int(event.data.bind_failed.err));
                                ^~~~~~~
src/caml_zmq_stubs.c:528:67: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 2, caml_copy_string(zmq_strerror(event.data.bind_failed.err)));
                                                                   ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:533:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.accepted.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:534:44: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_fd(event.data.accepted.fd));
                                            ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:27:21: note: in expansion of macro ‘Val_int’
 #  define Val_fd(x) Val_int(x)
                     ^~~~~~~
src/caml_zmq_stubs.c:534:32: note: in expansion of macro ‘Val_fd’
         Store_field(result, 1, Val_fd(event.data.accepted.fd));
                                ^~~~~~
src/caml_zmq_stubs.c:539:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.accept_failed.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:540:45: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_int(event.data.accept_failed.err));
                                             ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:540:32: note: in expansion of macro ‘Val_int’
         Store_field(result, 1, Val_int(event.data.accept_failed.err));
                                ^~~~~~~
src/caml_zmq_stubs.c:541:67: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 2, caml_copy_string(zmq_strerror(event.data.accept_failed.err)));
                                                                   ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:546:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.closed.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:547:44: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_fd(event.data.closed.fd));
                                            ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:27:21: note: in expansion of macro ‘Val_int’
 #  define Val_fd(x) Val_int(x)
                     ^~~~~~~
src/caml_zmq_stubs.c:547:32: note: in expansion of macro ‘Val_fd’
         Store_field(result, 1, Val_fd(event.data.closed.fd));
                                ^~~~~~
src/caml_zmq_stubs.c:552:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.close_failed.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:553:45: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_int(event.data.close_failed.err));
                                             ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:553:32: note: in expansion of macro ‘Val_int’
         Store_field(result, 1, Val_int(event.data.close_failed.err));
                                ^~~~~~~
src/caml_zmq_stubs.c:554:67: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 2, caml_copy_string(zmq_strerror(event.data.close_failed.err)));
                                                                   ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:559:54: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 0, caml_copy_string(event.data.disconnected.addr));
                                                      ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
src/caml_zmq_stubs.c:560:44: error: request for member ‘data’ in something not a structure or union
         Store_field(result, 1, Val_fd(event.data.disconnected.fd));
                                            ^
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/memory.h:353:27: note: in definition of macro ‘Store_field’
   value caml__temp_val = (val); \
                           ^~~
/home/copy/.opam/4.05.0+beta1+flambda/lib/ocaml/caml/mlvalues.h:77:20: note: in expansion of macro ‘Val_long’
 #define Val_int(x) Val_long(x)
                    ^~~~~~~~
src/caml_zmq_stubs.c:27:21: note: in expansion of macro ‘Val_int’
 #  define Val_fd(x) Val_int(x)
                     ^~~~~~~
src/caml_zmq_stubs.c:560:32: note: in expansion of macro ‘Val_fd’
         Store_field(result, 1, Val_fd(event.data.disconnected.fd));
                                ^~~~~~
Command exited with code 2.

Router not waking up to receive

I'm using two sockets connected via the 127.0.0.1.

I have the server bound onto port 56789 and the client connecting to it.

If the server starts up substantially before the client (on the order of 5s) and the receive method is hit on the server, when the client sends a message the server will not wake up.

Potentially important information is that this is using the latest version of ocaml-zmq and the server socket is a router while the client socket is a dealer.

Additionally by doing a tcpdump it appears that the zmq side of the situation is correctly acknowledging the communication.

Implement zmq-lwt.

Just a head up:

Now that we have a zmq-async, I have started working on zmq-lwt by creating a functor to abstract the concurrency monad.

This would essentially implement the same interface as https://github.com/hcarty/lwt-zmq/blob/master/src/lwt_zmq.ml, but keep the implementations identical, albait factorized by the concurrency monads (Async_kernel.Deferred.t / Lwt.t).

I will create a branch today, as I do have some questions about both implementations.

Releases via dune-release

I think it would be good to have dune-release cut the releases, since it can build the tarballs, upload them to Github, write the Changelog to the github release, generate the OPAM-Repository packages and create pull requests to submit to opam-repository.

I use it for my own projects and it works reasonably well. I tried to apply it here, but since this repository generates multiple packages there seems to be some kind of issue where it seems to ignore the async and lwt subpackages: tarides/dune-release#54

Package should not use oasis at install time

Using OASIS at install time is an antipattern, because the version of OASIS the user has does not necessarily match the one developer had. In practice, this leads to this bug: http://pastebin.com/PL4DqnRV. Key part: -ccopt '${pkg_uint_uint64}' is not expanded.

What you should do instead is to make a branch for every release, do oasis setup, commit the resulting generated files, and tag the commit. This is what pretty much all projects that use OASIS with github do.

Socket reaped by zmq while still in use

The Fedora project is attempting to update to OCaml 5.1.0. We are seeing segfaults in the ocaml-zmq test suite. We build for multiple architectures. On each build attempt, we saw such a segfault on only 1 of the target architectures, but a different architecture each time. The issue seems to occur most frequently on the ppc64le architecture, so I ran the test executable (_build/default/zmq/test/test.exe) under valgrind in a loop. It took awhile, but I eventually got this:

==501== Memcheck, a memory error detector
==501== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==501== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==501== Command: ./test.exe
==501== 
==501== Warning: set address range perms: large range [0x6290000, 0x162a0000) (noaccess)
.....==501== Thread 4:
==501== Invalid read of size 4
==501==    at 0x49D1A9C: zmq_getsockopt (zmq.cpp:245)
==501==    by 0x49D3B03: zmq_poll (zmq.cpp:999)
==501==    by 0x49A7747: zmq::proxy (proxy.cpp:573)
==501==    by 0x49D4CBB: zmq_proxy (zmq.cpp:1456)
==501==    by 0x1B377B: caml_zmq_proxy2 (caml_zmq_stubs.c:603)
==501==    by 0x1F6167: caml_interprete (in /builddir/build/BUILD/zmq-5.2.1/_build/default/zmq/test/test.exe)
==501==    by 0x1BDC0B: caml_callbackN_exn (in /builddir/build/BUILD/zmq-5.2.1/_build/default/zmq/test/test.exe)
==501==    by 0x1BDD43: caml_callback_exn (in /builddir/build/BUILD/zmq-5.2.1/_build/default/zmq/test/test.exe)
==501==    by 0x1A3FF7: caml_thread_start (in /builddir/build/BUILD/zmq-5.2.1/_build/default/zmq/test/test.exe)
==501==    by 0x4D413A3: start_thread (in /usr/lib64/libc.so.6)
==501==    by 0x4DF4A93: clone (in /usr/lib64/libc.so.6)
==501==  Address 0x6099418 is 1,560 bytes inside a block of size 1,824 free'd
==501==    at 0x48F5058: operator delete(void*, unsigned long) (vg_replace_malloc.c:1072)
==501==    by 0x49A7E93: zmq::pull_t::~pull_t() (pull.cpp:45)
==501==    by 0x49BE9F3: zmq::own_t::process_destroy() (own.cpp:211)
==501==    by 0x49BE9F3: zmq::socket_base_t::check_destroy() [clone .part.0] (socket_base.cpp:1716)
==501==    by 0x498479F: zmq::epoll_t::loop() (epoll.cpp:206)
==501==    by 0x499CE27: zmq::worker_poller_base_t::worker_routine(void*) (poller_base.cpp:146)
==501==    by 0x49C1DCB: thread_routine (thread.cpp:257)
==501==    by 0x4D413A3: start_thread (in /usr/lib64/libc.so.6)
==501==    by 0x4DF4A93: clone (in /usr/lib64/libc.so.6)
==501==  Block was alloc'd at
==501==    at 0x48F2074: operator new(unsigned long, std::nothrow_t const&) (vg_replace_malloc.c:592)
==501==    by 0x5808459B: ??? (in /usr/libexec/valgrind/memcheck-ppc64le-linux)
==501==    by 0x49D15AF: zmq_socket (zmq.cpp:259)
==501==    by 0x1B16AF: caml_zmq_socket (caml_zmq_stubs.c:151)
==501==    by 0x1F6167: caml_interprete (in /builddir/build/BUILD/zmq-5.2.1/_build/default/zmq/test/test.exe)
==501==    by 0x1F97EF: caml_startup_code_exn (in /builddir/build/BUILD/zmq-5.2.1/_build/default/zmq/test/test.exe)
==501==    by 0x1F9883: caml_startup_code (in /builddir/build/BUILD/zmq-5.2.1/_build/default/zmq/test/test.exe)
==501==    by 0x1A257B: main (camlprim.c:26772)
==501== 
.FError: Socket not closed before finalization
Error: Socket not closed before finalization
Error: Context not closed before finalization
......
==============================================================================
Failure: Zmq:0:zmq test:6:monitor

Wrong event received on m2
expected: Disconnect: ipc://monitor_socket but got: Monitor_stopped: 
------------------------------------------------------------------------------
Ran: 13 tests in: 3.55 seconds.
FAILED: Cases: 13 Tried: 13 Errors: 0 Failures: 1 Skip:  0 Todo: 0 Timeouts: 0.
==501== 
==501== HEAP SUMMARY:
==501==     in use at exit: 1,582,640 bytes in 135 blocks
==501==   total heap usage: 882 allocs, 747 frees, 2,984,863 bytes allocated
==501== 
==501== For a detailed leak analysis, rerun with: --leak-check=full
==501== 
==501== For lists of detected and suppressed errors, rerun with: -s
==501== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

I assume this is the test_proxy function in action. Does this perhaps mean that the "sleep 10" in the main thread expired before the child thread started running?

Socket options subtyping issue

I'm trying to write the following code:

let socket : [`Router] Zmq.Socket.t = Zmq.Socket.create context Zmq.Socket.router in
Zmq.Socket.set_probe_router socket true;

However I am getting an error

This expression has type [ `Router ] Zmq.Socket.t but an expression was expected of type [> `Dealer | `Req | `Router ] Zmq.Socket.t The first variant type does not allow tag(s) `Dealer, `Req

My understanding is that this is due to the typing restriction on set_probe_router.

However checking the equivalent of this in utop

type 'a box = Box of 'a

let (x : `A box ) = Box `A
let f : [`A | `B] box -> unit = fun b -> ()

f x fails with the same error, however
f (x :> ['A | 'B] box) works as expected.

Attempting a similar approach above however fails stating that
Type [ `Router ] Zmq.Socket.t is not a subtype of [ `Dealer | `Req | `Router ] Zmq.Socket.t

This is ocaml 4.08.0 that this occurs.

Should also depend on conf-libsodium?

At least when compiling statically, it seems to be necessary:

/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lsodium

opam depext --install conf-libsodium makes it go away.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.