X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/58bce89d599a5bee49318c168f54fb407fbf5d24..bce68420986fe0f0a060cde4e5c86e44c94b82e9:/doc/gtut-files/06-logs.c diff --git a/doc/gtut-files/06-logs.c b/doc/gtut-files/06-logs.c index 1fff408adf..f0acfb7cd1 100644 --- a/doc/gtut-files/06-logs.c +++ b/doc/gtut-files/06-logs.c @@ -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 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_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) { @@ -25,7 +31,7 @@ int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) { INFO2("Cool, we received the message from %s:%d.", gras_socket_peer_name(client), gras_socket_peer_port(client)); - return 1; + return 0; } /* end_of_hello_callback */ int server(int argc, char *argv[]) { @@ -41,8 +47,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 */ @@ -67,13 +73,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); INFO1("we sent the data to the server on %s. Let's do it again for fun", gras_socket_peer_name(toserver)); - gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL); + gras_msg_send(toserver,"hello", NULL); INFO0("Ok. Enough. Have a rest, and then kill the server"); 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;