From e98bc8d7a6937c49670e601d09b0299fd8ae5165 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 28 May 2024 11:11:33 +0200 Subject: [PATCH] lookup localhost ip in precompile bind not all versions of libzmq support binding to a hostname --- src/ZMQ.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ZMQ.jl b/src/ZMQ.jl index 71d3097..3bf8118 100644 --- a/src/ZMQ.jl +++ b/src/ZMQ.jl @@ -58,12 +58,14 @@ import PrecompileTools: @compile_workload s2=Socket(REQ) - ZMQ.bind(s1, "tcp://localhost:*") + # zmq < 4.3.5 can only bind to ip address or network interface, not hostname + localhost_ip = Sockets.getaddrinfo("localhost", Sockets.IPv4) + ZMQ.bind(s1, "tcp://$(localhost_ip):*") # Strip the trailing null-terminator last_endpoint = s1.last_endpoint[1:end - 1] # Parse the port from the endpoint port = parse(Int, split(last_endpoint, ":")[end]) - ZMQ.connect(s2, "tcp://localhost:$(port)") + ZMQ.connect(s2, "tcp://$(localhost_ip):$(port)") msg = Message("test request")