(bind-func fleet_message_all_nodes_sync
(let ((buf:i8* (zalloc (* FLEET_NODE_MAX FLEET_NANOMSG_CLIENT_BUFLEN))))
(lambda (msg:i8*)
(if (null? FLEET_NODE_SOCKET_LIST)
(println "Error: FLEET_NODE_SOCKET_LIST is null.")
(let ((sz_msg (+ (strlen msg) 1)))
;; send out the messages (scatter)
(for-each (lambda (sock)
(nn_sock_set_timeout sock 1000)
(nn_send sock msg sz_msg NN_DONTWAIT))
FLEET_NODE_SOCKET_LIST)
;; wait to recieve on all sockets (gather)
(for-each (lambda (sock)
(let ((offset (* (index_of sock FLEET_NODE_SOCKET_LIST)
FLEET_NANOMSG_CLIENT_BUFLEN))
(rbytes (nn_recv sock (pref-ptr buf offset) FLEET_NANOMSG_CLIENT_BUFLEN 0)))
(if (> rbytes 0)
(begin (printf "[%d] %s\n" sock (pref-ptr buf offset))
void))))
FLEET_NODE_SOCKET_LIST))))))