/* 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. */
-#define GRAS_DEFINE_TYPE_EXTERN
+#define XBT_DEFINE_TYPE_EXTERN
#include "xbt/matrix.h"
#include "mmrpc.h"
(common to client and server) */
void mmrpc_register_messages(void)
{
- gras_datadesc_type_t matrix_type, request_type;
+ xbt_datadesc_type_t matrix_type, request_type;
- matrix_type = gras_datadesc_matrix(gras_datadesc_by_name("double"),
+ matrix_type = xbt_datadesc_matrix(xbt_datadesc_by_name("double"),
NULL);
request_type =
- gras_datadesc_array_fixed("s_matrix_t(double)[2]", matrix_type, 2);
+ xbt_datadesc_array_fixed("s_matrix_t(double)[2]", matrix_type, 2);
gras_msgtype_declare("answer", matrix_type);
gras_msgtype_declare("request", request_type);
void *payload_data)
{
- gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+ xbt_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
/* 1. Get the payload into the data variable */
xbt_matrix_t *request = (xbt_matrix_t *) payload_data;
int server(int argc, char *argv[])
{
- xbt_ex_t e;
- gras_socket_t sock = NULL;
+ xbt_socket_t sock = NULL;
int port = 4000;
/* 1. Init the GRAS infrastructure */
TRY {
sock = gras_socket_server(port);
}
- CATCH(e) {
- RETHROW0("Unable to establish a server socket: %s");
+ CATCH_ANONYMOUS {
+ RETHROWF("Unable to establish a server socket: %s");
}
/* 4. Register the known messages and payloads. */
/* 5. Register my callback */
gras_cb_register("request", &server_cb_request_handler);
- /* 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(600.0);
/* 7. Free the allocated resources, and shut GRAS down */
int client(int argc, char *argv[])
{
- xbt_ex_t e;
- gras_socket_t toserver = NULL; /* peer */
+ xbt_socket_t toserver = NULL; /* peer */
- gras_socket_t from;
+ xbt_socket_t from;
xbt_matrix_t request[2], answer;
int i, j;
TRY {
toserver = gras_socket_client(host, port);
}
- CATCH(e) {
- RETHROW0("Unable to connect to the server: %s");
+ CATCH_ANONYMOUS {
+ RETHROWF("Unable to connect to the server: %s");
}
XBT_INFO("Connected to %s:%d.", host, port);
/* 6. Keep the user informed of what's going on */
XBT_INFO(">>>>>>>> Connected to server which is on %s:%d <<<<<<<<",
- gras_socket_peer_name(toserver), gras_socket_peer_port(toserver));
+ xbt_socket_peer_name(toserver), xbt_socket_peer_port(toserver));
/* 7. Prepare and send the request to the server */
xbt_matrix_free(request[0]);
XBT_INFO(">>>>>>>> Request sent to %s:%d <<<<<<<<",
- gras_socket_peer_name(toserver), gras_socket_peer_port(toserver));
+ xbt_socket_peer_name(toserver), xbt_socket_peer_port(toserver));
/* 8. Wait for the answer from the server, and deal with issues */
gras_msg_wait(6000, "answer", &from, &answer);
*/
for (i = 0; i < MATSIZE; i++)
for (j = 0; i < MATSIZE; i++)
- xbt_assert4(xbt_matrix_get_as(answer, i, j, double) ==
+ xbt_assert(xbt_matrix_get_as(answer, i, j, double) ==
xbt_matrix_get_as(request[1], i, j, double),
"Answer does not match expectations. Found %f at cell %d,%d instead of %f",
xbt_matrix_get_as(answer, i, j, double), i, j,
/* 9. Keep the user informed of what's going on, again */
XBT_INFO(">>>>>>>> Got answer from %s:%d (values are right) <<<<<<<<",
- gras_socket_peer_name(from), gras_socket_peer_port(from));
+ xbt_socket_peer_name(from), xbt_socket_peer_port(from));
/* 10. Free the allocated resources, and shut GRAS down */
xbt_matrix_free(request[1]);