/* ping - ping/pong demo of GRAS features */
-/* Authors: Martin Quinson */
-/* Copyright (C) 2003 the OURAGAN project. */
+/* Copyright (c) 2003, 2004 Martin Quinson. 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. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#include <stdio.h>
#include <stdlib.h>
#include "gras.h"
-GRAS_LOG_NEW_DEFAULT_CATEGORY(Ping,"Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(Ping,"Messages specific to this example");
/* **********************************************************************
* Comon code
int server_cb_ping_handler(gras_socket_t expeditor,
void *payload_data) {
- gras_error_t errcode;
+ xbt_error_t errcode;
int msg=*(int*)payload_data;
gras_msgtype_t *pong_t=NULL;
errcode = gras_msg_send(expeditor, gras_msgtype_by_name("pong"), &msg);
if (errcode != no_error) {
- ERROR1("SERVER: Unable answer with PONG: %s\n", gras_error_name(errcode));
+ ERROR1("SERVER: Unable answer with PONG: %s\n", xbt_error_name(errcode));
gras_socket_close(g->sock);
return 1;
}
}
int server (int argc,char *argv[]) {
- gras_error_t errcode;
+ xbt_error_t errcode;
server_data_t *g;
gras_msgtype_t *ping_msg=NULL;
int port = 4000;
- gras_init(&argc,argv);
+ gras_init(&argc,argv, NULL);
g=gras_userdata_new(server_data_t);
if (argc == 2) {
if ((errcode=gras_socket_server(port,&(g->sock)))) {
CRITICAL1("Error %s encountered while opening the server socket",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
if (!gras_if_RL())
gras_os_sleep(1,0);
+
gras_socket_close(g->sock);
free(g);
gras_exit();
int client (int argc,char *argv[]);
int client(int argc,char *argv[]) {
- gras_error_t errcode;
+ xbt_error_t errcode;
client_data_t *g;
gras_socket_t from;
const char *host = "127.0.0.1";
int port = 4000;
- gras_init(&argc, argv);
+ gras_init(&argc, argv, NULL);
g=gras_userdata_new(client_data_t);
if (argc == 3) {
gras_os_sleep(1,0); /* Wait for the server startup */
if ((errcode=gras_socket_client(host,port,&(g->sock)))) {
ERROR1("Client: Unable to connect to the server. Got %s",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
INFO2("Client: Connected to %s:%d.",host,port);
errcode = gras_msg_send(g->sock, gras_msgtype_by_name("ping"), &ping);
if (errcode != no_error) {
fprintf(stderr, "Client: Unable send PING to server (%s)\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_socket_close(g->sock);
return 1;
}
if ((errcode=gras_msg_wait(6000,gras_msgtype_by_name("pong"),
&from,&pong))) {
ERROR1("Client: Why can't I get my PONG message like everyone else (%s)?",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_socket_close(g->sock);
return 1;
}