Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
We need the os threads here
[simgrid.git] / doc / gtut-files / 05-globals.c
index 9ca9c17..6b9d974 100644 (file)
@@ -14,7 +14,7 @@ int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   
   globals->killed = 1;
    
-  return 1;
+  return 0;
 } /* end_of_kill_callback */
 
 int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
@@ -23,7 +23,7 @@ int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   fprintf(stderr,"Cool, we received the message from %s:%d.\n",
          gras_socket_peer_name(client), gras_socket_peer_port(client));
   
-  return 1;
+  return 0;
 } /* end_of_hello_callback */
 
 int server(int argc, char *argv[]) {
@@ -39,8 +39,8 @@ int server(int argc, char *argv[]) {
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
    
-  gras_cb_register(gras_msgtype_by_name("hello"),&server_hello_cb);   
-  gras_cb_register(gras_msgtype_by_name("kill"),&server_kill_cb);
+  gras_cb_register("hello",&server_hello_cb);   
+  gras_cb_register("kill",&server_kill_cb);
 
   while (!globals->killed) {
      gras_msg_handle(-1); /* blocking */
@@ -65,13 +65,13 @@ int client(int argc, char *argv[]) {
   gras_os_sleep(1.5); /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
   
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(toserver,"hello", NULL);
   fprintf(stderr,"we sent the data to the server on %s. Let's do it again for fun\n", gras_socket_peer_name(toserver));
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(toserver,"hello", NULL);
    
   fprintf(stderr,"Ok. Enough. Have a rest, and then kill the server\n");
   gras_os_sleep(5); /* sleep 1 second and half */
-  gras_msg_send(toserver,gras_msgtype_by_name("kill"), NULL);
+  gras_msg_send(toserver,"kill", NULL);
 
   gras_exit();
   return 0;