Skip to content

Commit 91a304c

Browse files
authored
Merge pull request #237 from minrk/precompile-bind
lookup localhost ip in precompile bind
2 parents bae8c69 + e98bc8d commit 91a304c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ZMQ.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ import PrecompileTools: @compile_workload
5858

5959
s2=Socket(REQ)
6060

61-
ZMQ.bind(s1, "tcp://localhost:*")
61+
# zmq < 4.3.5 can only bind to ip address or network interface, not hostname
62+
localhost_ip = Sockets.getaddrinfo("localhost", Sockets.IPv4)
63+
ZMQ.bind(s1, "tcp://$(localhost_ip):*")
6264
# Strip the trailing null-terminator
6365
last_endpoint = s1.last_endpoint[1:end - 1]
6466
# Parse the port from the endpoint
6567
port = parse(Int, split(last_endpoint, ":")[end])
66-
ZMQ.connect(s2, "tcp://localhost:$(port)")
68+
ZMQ.connect(s2, "tcp://$(localhost_ip):$(port)")
6769

6870
msg = Message("test request")
6971

0 commit comments

Comments
 (0)