(bind-func fleet_connect_to_nodes
"creates new sockets each call - TODO: it should re-use existing ones"
(lambda (host port)
(set! FLEET_NODE_SOCKET_LIST
(copy_h ;; copy the list to the heap - it's a global list
(map (lambda (ip)
(printf "Connecting to node at %s ..." (cstring ip))
(let ((sock (create_socket NN_REQ))
(addr:i8* (salloc 32)))
(sprintf addr "tcp://%s:7199" (cstring ip))
(if (or (< sock 0)
(< (connect_socket sock addr) 0))
(nn_println_strerror "error in fleet_connect_to_nodes"))
(printf "sock = %d\n" sock)
sock))
(fleet_get_ip_list host port))))))