Skip to content

Commit

Permalink
Merge pull request #125 from djellemah/master
Browse files Browse the repository at this point in the history
add Socket.set_stream_notify
  • Loading branch information
andersfugmann authored Nov 23, 2022
2 parents bca6681 + 833a13d commit 8a24cd0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions zmq/src/caml_zmq_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ static int const native_int_option_for[] = {
ZMQ_REQ_CORRELATE,
ZMQ_REQ_RELAXED,
ZMQ_CONFLATE,
ZMQ_STREAM_NOTIFY
};

CAMLprim value caml_zmq_set_int_option(value socket, value option_name, value socket_option) {
Expand Down
4 changes: 4 additions & 0 deletions zmq/src/zmq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ module Socket = struct
| ZMQ_REQ_CORRELATE
| ZMQ_REQ_RELAXED
| ZMQ_CONFLATE
| ZMQ_STREAM_NOTIFY
[@@@warning "+37"]

external set_int_option :
Expand Down Expand Up @@ -483,6 +484,9 @@ module Socket = struct
let set_conflate socket flag =
set_int_option socket ZMQ_CONFLATE (if flag then 1 else 0)

let set_stream_notify socket stream_notify_flag =
set_int_option socket ZMQ_STREAM_NOTIFY (if stream_notify_flag then 1 else 0)

external get_fd : 'a t -> Unix.file_descr = "caml_zmq_get_fd"

type event = No_event | Poll_in | Poll_out | Poll_in_out | Poll_error
Expand Down
1 change: 1 addition & 0 deletions zmq/src/zmq.mli
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ module Socket : sig
val set_zap_domain : 'a t -> string -> unit
val get_zap_domain : 'a t -> string
val set_conflate : [< `Pull | `Push | `Sub | `Pub | `Dealer] t -> bool -> unit
val set_stream_notify : [< `Stream ] t -> bool -> unit

val get_fd : 'a t -> Unix.file_descr

Expand Down
7 changes: 7 additions & 0 deletions zmq/test/zmq_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ let test_socket_options () =
test_set_get_value "Tcp keepalive interval" set_tcp_keepalive_interval get_tcp_keepalive_interval socket (`Value 1000);

Socket.close socket;

(* Must be a `Stream. No getter so just test that it doesn't explode. *)
let stream_socket = create ctx stream in
set_stream_notify stream_socket true;
set_stream_notify stream_socket false;
Socket.close stream_socket;

Context.terminate ctx;
()

Expand Down

0 comments on commit 8a24cd0

Please sign in to comment.