X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6760cb07d6b57be16928d95339d71e57c4e24f36..bed55a06c0de08698519ba251e4c4298cc2ff4b6:/examples/gras/ping/ping_server.c diff --git a/examples/gras/ping/ping_server.c b/examples/gras/ping/ping_server.c index 27597d9e67..ccb590c438 100644 --- a/examples/gras/ping/ping_server.c +++ b/examples/gras/ping/ping_server.c @@ -12,18 +12,16 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(Ping); /* Global private data */ typedef struct { - gras_socket_t sock; + xbt_socket_t sock; int endcondition; } server_data_t; static int server_cb_ping_handler(gras_msg_cb_ctx_t ctx, void *payload) { - - xbt_ex_t e; /* 1. Get the payload into the msg variable, and retrieve my caller */ int msg = *(int *) payload; - gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx); + xbt_socket_t expeditor = gras_msg_cb_ctx_from(ctx); /* 2. Retrieve the server's state (globals) */ @@ -31,9 +29,10 @@ static int server_cb_ping_handler(gras_msg_cb_ctx_t ctx, void *payload) globals->endcondition = 0; /* 3. Log which client connected */ - INFO3(">>>>>>>> Got message PING(%d) from %s:%d <<<<<<<<", + XBT_INFO(">>>>>>>> Got message PING(%d) from %s:%d <<<<<<<<", msg, - gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor)); + xbt_socket_peer_name(expeditor), + xbt_socket_peer_port(expeditor)); /* 4. Change the value of the msg variable */ msg = 4321; @@ -42,12 +41,13 @@ static int server_cb_ping_handler(gras_msg_cb_ctx_t ctx, void *payload) gras_msg_send(expeditor, "pong", &msg); /* 6. Deal with errors: add some details to the exception */ - } CATCH(e) { + } + CATCH_ANONYMOUS { gras_socket_close(globals->sock); - RETHROW0("Unable answer with PONG: %s"); + RETHROWF("Unable answer with PONG: %s"); } - INFO0(">>>>>>>> Answered with PONG(4321) <<<<<<<<"); + XBT_INFO(">>>>>>>> Answered with PONG(4321) <<<<<<<<"); /* 7. Set the endcondition boolean to true (and make sure the server stops after receiving it). */ globals->endcondition = 1; @@ -71,7 +71,7 @@ int server(int argc, char *argv[]) port = atoi(argv[1]); } - INFO1("Launch server (port=%d)", port); + XBT_INFO("Launch server (port=%d)", port); /* 3. Create my master socket */ globals->sock = gras_socket_server(port); @@ -84,21 +84,22 @@ int server(int argc, char *argv[]) /* 5. Register my callback */ gras_cb_register("ping", &server_cb_ping_handler); - INFO1(">>>>>>>> Listening on port %d <<<<<<<<", - gras_socket_my_port(globals->sock)); + XBT_INFO(">>>>>>>> Listening on port %d <<<<<<<<", + xbt_socket_my_port(globals->sock)); globals->endcondition = 0; - /* 6. Wait up to 10 minutes for an incomming message to handle */ + /* 6. Wait up to 10 minutes for an incoming message to handle */ gras_msg_handle(10.0); /* 7. Housekeeping */ if (!globals->endcondition) - WARN0("An error occured, the endcondition was not set by the callback"); + XBT_WARN + ("An error occured, the endcondition was not set by the callback"); /* 8. Free the allocated resources, and shut GRAS down */ gras_socket_close(globals->sock); free(globals); - INFO0("Done."); + XBT_INFO("Done."); gras_exit(); return 0;