JuliaLang/julia — pull request #1879 by swadey (2013-01-03 01:42:18+00:00)
Title: allow worker to work when a host has multiple IP addresses

This is the body of the email i sent to julia-dev:

I've been trying to run a couple of parallel things and I've come across two problems:

1. I'm unable to start julia with workers when I'm connected to my institute's vpn. I get this error:

$ julia -p 4
could not connect to 192.168.1.106:9012, errno=60

in Worker at multi.jl:110
in Worker at multi.jl:115
in start_remote_workers at multi.jl:947
in addprocs_local at multi.jl:1008
in process_options at client.jl:202
in _start at client.jl:255

The problem seems to be that when julia launches workers, it expects them to report their IP addresses (even if the worker is started locally). If a machine has multiple addresses, the first non loopback adapter is chosen (via a call to getipaddr() which c-calls getlocalip()), which results in:

$ julia --worker
julia_worker:9021#192.168.1.106

The problem is that many VPNs (including our) don't allow bridging, so when the VPN is connected, connections to the primary adapter are blocked.

I worked around this by adding a mode argument to --worker:

--worker local
--worker remote

start_worker() checks this flag to decide whether to use "localhost" or the result of getipaddr().