X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/75e7f54eae118276872fa0c77812e4d0a7db8152..60a7fb293cd43bfeaab1d30dc06a1e5d6d258493:/examples/gras/all2all/all2all.c diff --git a/examples/gras/all2all/all2all.c b/examples/gras/all2all/all2all.c index fadca1c806..5c029dad7d 100644 --- a/examples/gras/all2all/all2all.c +++ b/examples/gras/all2all/all2all.c @@ -28,7 +28,7 @@ int receiver (int argc,char *argv[]) { int myport; /* port on which I receive stuff */ int todo; /* amount of messages I should get */ - int data; /* message content */ + char *data; /* message content */ gras_socket_t mysock; /* socket on which other people contact me */ gras_socket_t expeditor; /* to notice who wrote me */ @@ -44,7 +44,7 @@ int receiver (int argc,char *argv[]) { mysock = gras_socket_server(myport); /* Register the known messages */ - gras_msgtype_declare("data", gras_datadesc_by_name("int")); + gras_msgtype_declare("data", gras_datadesc_by_name("string")); /* Get the data */ @@ -58,16 +58,15 @@ int receiver (int argc,char *argv[]) { &data); todo--; - INFO4("Got Data(%d) from %s:%d (still %d to go)", - data, + INFO3("Got Data from %s:%d (still %d to go)", gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor), todo); } - + /* Free the allocated resources, and shut GRAS down */ gras_socket_close(mysock); - + gras_exit(); return 0; } /* end_of_receiver */ @@ -79,45 +78,52 @@ int receiver (int argc,char *argv[]) { int sender (int argc,char *argv[]) { int i; /* iterator */ - int data; /* data exchanged */ - - xbt_host_t h; /* iterator */ + char *data; /* data exchanged */ + int datasize; /* size of message */ + xbt_peer_t h; /* iterator */ gras_socket_t peer; /* socket to node */ + - /* xbt_dynar for hosts */ - xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&xbt_host_free_voidp); + /* xbt_dynar for peers */ + xbt_dynar_t peers = xbt_dynar_new(sizeof(xbt_peer_t),&xbt_peer_free_voidp); /* Init the GRAS infrastructure and declare my globals */ gras_init(&argc,argv); /* Get the node location from argc/argv */ - for (i=2; iname,h->port); gras_msg_send(peer,gras_msgtype_by_name("data"),&data); - INFO3(" Sent Data (%d) from %s to %s", - data,gras_os_myname(),h->name); + INFO2(" Sent Data from %s to %s", + gras_os_myname(),h->name); gras_socket_close(peer); } /* Free the allocated resources, and shut GRAS down */ - xbt_dynar_free(&hosts); + xbt_dynar_free(&peers); gras_exit(); return 0;