Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Doc for examples icomms.
[simgrid.git] / doc / gtut-files / 08-exceptions.c
index fd3a407..6b90168 100644 (file)
@@ -1,3 +1,9 @@
+/* Copyright (c) 2006, 2007, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+  * under the terms of the license (GNU LGPL) which comes with this package. */
+
 #include <gras.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"My little example");
@@ -16,7 +22,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(int argc, char *argv[]) {
@@ -29,7 +35,7 @@ int server(int argc, char *argv[]) {
   globals->killed=0;
 
   gras_msgtype_declare("kill", NULL);
-  gras_cb_register(gras_msgtype_by_name("kill"),&server_kill_cb);
+  gras_cb_register("kill",&server_kill_cb);
    
   if (argc>1 && !strcmp(argv[1],"--cheat")) {
      mysock = gras_socket_server(9999);
@@ -65,7 +71,7 @@ int client(int argc, char *argv[]) {
   for (port=3000, found=0; port<3010 && !found; port++) {
      TRY {
        toserver = gras_socket_client(argv[1], port);
-       gras_msg_send(toserver,gras_msgtype_by_name("kill"), NULL);
+       gras_msg_send(toserver,"kill", NULL);
        gras_socket_close(toserver);
        found = 1;
        INFO1("Yeah! I found the server on %d! It's eradicated by now.",port);