-static int node_cb_data_handler(gras_msg_cb_ctx_t ctx,
- void *payload_data) {
-
- /* Get the payload into the msg variable */
- int data=*(int*)payload_data;
-
- gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
-
- /* Retrieve the server's state (globals) */
-
- node_data_t *globals=(node_data_t*)gras_userdata_get();
- globals->done = 0;
-
- /* Log which client connected */
- INFO3(">>>>>>>> Got Data(%d) from %s:%d <<<<<<<<",
- data,
- gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor));
-
- /* Set the done boolean to true (and make sure the server stops after receiving it). */
- globals->done = 1;
-
- /* Make sure we don't leak sockets */
- //gras_socket_close(expeditor);
-
- /* Tell GRAS that we consummed this message */
- return 1;
-} /* end_of_server_cb_ping_handler */
-
-int node (int argc,char *argv[]) {
-
- xbt_ex_t e;
-
- int port,nb_hosts,data,
- i,done;
-
- xbt_host_t h1;
-
- gras_socket_t peer; /* socket to node */
-
- node_data_t *globals;
-
- /* xbt_dynar for hosts */
- xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host);
-
- /* Init the GRAS infrastructure and declare my globals */
- gras_init(&argc,argv);
-
- globals=gras_userdata_new(node_data_t *);
+ /* Register the known messages */
+ gras_msgtype_declare("data", gras_datadesc_by_name("string"));
+
+ /* Create my master socket */
+ mysock = gras_socket_server(myport);
+
+ /* Get the data */
+ XBT_INFO("Listening on port %d (expecting %d messages)",
+ gras_socket_my_port(mysock), todo);
+ while (todo > 0) {
+ gras_msg_wait(60 /* wait up to one minute */ ,
+ "data", &expeditor, &data);
+ todo--;
+ free(data);
+
+ XBT_INFO("Got Data from %s:%d (still %d to go)",
+ gras_socket_peer_name(expeditor),
+ gras_socket_peer_port(expeditor), todo);