Skip to content

Commit

Permalink
Merge pull request #237 from minrk/precompile-bind
Browse files Browse the repository at this point in the history
lookup localhost ip in precompile bind
  • Loading branch information
JamesWrigley authored May 28, 2024
2 parents bae8c69 + e98bc8d commit 91a304c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ZMQ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 91a304c

Please sign in to comment.