@@ -208,6 +208,7 @@ mutable struct LocalProcess
208
208
id0:: Int
209
209
id1:: Int
210
210
bind_addr:: String
211
+ bind_addr_2:: String
211
212
bind_port:: UInt16
212
213
cookie:: String
213
214
LocalProcess () = new (1 ,1 )
@@ -273,7 +274,7 @@ function start_worker(out::IO, cookie::AbstractString=readline(stdin); close_std
273
274
client = accept (sock)
274
275
process_messages (client, client, true ; role = :worker )
275
276
end )
276
- println (out, " julia_worker:$(string (LPROC. bind_port)) #$(LPROC. bind_addr ) \n " ) # print header
277
+ println (out, " julia_worker:$(string (LPROC. bind_port)) #$(LPROC. bind_addr_2 ) \n " ) # print header
277
278
flush (out)
278
279
279
280
Sockets. nagle (sock, false )
@@ -1384,7 +1385,7 @@ function terminate_all_workers(;role= :default)
1384
1385
end
1385
1386
1386
1387
# initialize the local proc network address / port
1387
- function init_bind_addr ()
1388
+ #= function init_bind_addr()
1388
1389
opts = JLOptions()
1389
1390
if opts.bindto != C_NULL
1390
1391
bind_to = split(unsafe_string(opts.bindto), ":")
@@ -1413,6 +1414,43 @@ function init_bind_addr()
1413
1414
LPROC.bind_addr = bind_addr
1414
1415
LPROC.bind_port = UInt16(bind_port)
1415
1416
end
1417
+ =#
1418
+
1419
+ function init_bind_addr ()
1420
+ opts = JLOptions ()
1421
+
1422
+ @info " A2: $(getipaddrs (IPv4; loopback = false )) "
1423
+ bind_port = 0
1424
+ try
1425
+ ips = getipaddrs (IPv4; loopback = false )
1426
+ n = length (ips)
1427
+ bind_addr = string (ips[n])
1428
+ # @info "ADDR: $(getipaddrs())"
1429
+ catch
1430
+ # All networking is unavailable, initialize bind_addr to the loopback address
1431
+ # Will cause an exception to be raised only when used.
1432
+ bind_addr = " 127.0.0.1"
1433
+ end
1434
+
1435
+ if opts. bindto != C_NULL
1436
+ bind_to = split (unsafe_string (opts. bindto), " :" )
1437
+ @info " A1: $bind_to "
1438
+ bind_addr_2 = string (parse (IPAddr, bind_to[1 ]))
1439
+ if length (bind_to) > 1
1440
+ bind_port = parse (Int,bind_to[2 ])
1441
+ else
1442
+ bind_port = 0
1443
+ end
1444
+ else
1445
+ bind_addr_2 = bind_addr
1446
+ end
1447
+
1448
+ global LPROC
1449
+ LPROC. bind_addr = bind_addr
1450
+ LPROC. bind_addr_2 = bind_addr_2
1451
+ LPROC. bind_port = UInt16 (bind_port)
1452
+ end
1453
+
1416
1454
1417
1455
using Random: randstring
1418
1456
0 commit comments