From 591f0306eaf2e69c9dba376608bd77c851354aec Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 5 Feb 2016 00:41:10 +0100 Subject: [PATCH] Deterministic ZMQ ports --- ocaml/Qmcchem_dataserver.ml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ocaml/Qmcchem_dataserver.ml b/ocaml/Qmcchem_dataserver.ml index e424676..8efeb33 100644 --- a/ocaml/Qmcchem_dataserver.ml +++ b/ocaml/Qmcchem_dataserver.ml @@ -71,8 +71,6 @@ let run ?(daemon=true) ezfio_filename = - (* - (** Checks if the port is already open (not working properly yet) *) let check_port n = let adress_prefix = "tcp://*:" @@ -87,7 +85,9 @@ let run ?(daemon=true) ezfio_filename = in let result = try - (ZMQ.Socket.bind socket address; accu ); + ZMQ.Socket.bind socket address; + ZMQ.Socket.unbind socket address; + accu; with | _ -> false; in @@ -100,22 +100,18 @@ let run ?(daemon=true) ezfio_filename = else `Unavailable in - *) (** Random port number between 49152 and 65535 *) let port = let newport = - (* ref (49152 + (Random.int 16383)) *) - ref ( 1024 + (Random.int (49151-1024))) + ref 10000 in - (* while ((check_port !newport) = `Unavailable) do - newport := 49152 + (Random.int 16383) + newport := !newport + 100 done; - *) !newport in