Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Chapter 3
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 15 Jul 2006 17:34:09 +0000 (17:34 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sat, 15 Jul 2006 17:34:09 +0000 (17:34 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2579 48e7efb5-ca39-0410-a469-dd3cf9ba447f

doc/gtut-files/.cvsignore [new file with mode: 0644]
doc/gtut-files/1-bones.output
doc/gtut-files/3-args.c [new file with mode: 0644]
doc/gtut-files/3-args.xml [new file with mode: 0644]
doc/gtut-files/Makefile

diff --git a/doc/gtut-files/.cvsignore b/doc/gtut-files/.cvsignore
new file mode 100644 (file)
index 0000000..8e4bb79
--- /dev/null
@@ -0,0 +1,25 @@
+1-bones.mk
+1-bones.trace
+1-bones_client
+1-bones_server
+1-bones_simulator
+_1-bones_client.c
+_1-bones_server.c
+_1-bones_simulator.c
+_2-simple_client.c
+_2-simple_server.c
+_2-simple_simulator.c
+2-simple.mk
+2-simple.trace
+2-simple_client
+2-simple_server
+2-simple_simulator
+3-args.mk
+3-args.output
+3-args.trace
+3-args_client
+3-args_server
+3-args_simulator
+_3-args_client.c
+_3-args_server.c
+_3-args_simulator.c
index 2a079b1..014775c 100644 (file)
@@ -1,7 +1,7 @@
 $ ./test_client
-[blaise:client:(27306) 0.000004] gras/gras.c:79: [gras/INFO] Exiting GRAS
+[blaise:client:(22033) 0.000005] gras/gras.c:79: [gras/INFO] Exiting GRAS
 $ ./test_server
-[blaise:server:(27309) 0.000005] gras/gras.c:79: [gras/INFO] Exiting GRAS
+[blaise:server:(22036) 0.000004] gras/gras.c:79: [gras/INFO] Exiting GRAS
 $ ./test_simulator platform.xml test.xml
 [Jacquelin:server:(1) 0.000000] gras/gras.c:79: [gras/INFO] Exiting GRAS
 [Boivin:client:(2) 0.000000] gras/gras.c:79: [gras/INFO] Exiting GRAS
diff --git a/doc/gtut-files/3-args.c b/doc/gtut-files/3-args.c
new file mode 100644 (file)
index 0000000..e4875ac
--- /dev/null
@@ -0,0 +1,39 @@
+#include <gras.h>
+
+int server(int argc, char *argv[]) {
+  gras_socket_t mysock;   /* socket on which I listen */
+  gras_socket_t toclient; /* socket used to write to the client */
+  
+  gras_init(&argc,argv);
+
+  gras_msgtype_declare("hello", NULL);
+  mysock = gras_socket_server(atoi(argv[1]));
+
+  gras_msg_wait(60, gras_msgtype_by_name("hello"), &toclient, NULL /* no payload */);
+  
+  fprintf(stderr,"Cool, we received the message from %s:%d.\n",
+         gras_socket_peer_name(toclient), gras_socket_peer_port(toclient));
+  
+  gras_exit();
+  return 0;
+}
+int client(int argc, char *argv[]) {
+  gras_socket_t mysock;   /* socket on which I listen */
+  gras_socket_t toserver; /* socket used to write to the server */
+
+  gras_init(&argc,argv);
+
+  gras_msgtype_declare("hello", NULL);
+  mysock = gras_socket_server_range(1024, 10000, 0, 0);
+  
+  fprintf(stderr,"Client ready; listening on %d\n", gras_socket_my_port(mysock));
+  
+  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);
+  fprintf(stderr,"That's it, we sent the data to the server on %s\n", gras_socket_peer_name(toserver));
+
+  gras_exit();
+  return 0;
+}
diff --git a/doc/gtut-files/3-args.xml b/doc/gtut-files/3-args.xml
new file mode 100644 (file)
index 0000000..274c91c
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform_description SYSTEM "surfxml.dtd">
+<platform_description version="1">
+  <process host="Jacquelin" function="server">
+    <argument value="12345"/>
+  </process>
+  <process host="Boivin" function="client">
+    <argument value="Jacquelin"/>
+    <argument value="12345"/>
+  </process>
+</platform_description>
+
index 99ba5a9..b5bed15 100644 (file)
@@ -1,7 +1,7 @@
 # This works mainly on my box for now
 export LD_LIBRARY_PATH=$(GRAS_ROOT)/lib
 
-all: 1-bones 2-simple
+all: 1-bones.output 2-simple.output 3-args.output
 
 veryclean: clean
        rm *.output
@@ -9,7 +9,6 @@ veryclean: clean
 # Lesson 1: simple bones of project
 ########################################
 
-1-bones: 1-bones.output
 1-bones.output: 1-bones_client 1-bones_server 1-bones_simulator
        echo '$$ ./test_client'                           > $@ 
        ./1-bones_client                                 >> $@ 2>&1
@@ -32,7 +31,6 @@ clean::
 # Lesson 2: simple message exchange
 ########################################
 
-2-simple: 2-simple.output
 2-simple.output: 2-simple_client 2-simple_server 2-simple_simulator
        echo '$$ ./test_simulator platform.xml test.xml'  > $@
        ./2-simple_simulator gtut-platform.xml test.xml  >> $@ 2>&1
@@ -48,4 +46,25 @@ clean::
        if [ -e 2-simple.mk ] ; then make -f 2-simple.mk clean; fi
        rm -f _2-simple_client.c _2-simple_server.c _2-simple_simulator.c 2-simple.trace 2-simple.mk
 
-.PHONY: 1-bones 2-simple
+# Lesson 3: passing args to processes
+########################################
+
+3-args.output: 3-args_client 3-args_server 3-args_simulator
+       echo '$$ ./test_server 12345 & ./test_client 127.0.0.1 12345'  > $@ 
+       ./3-args_server 12345                                         >> $@ 2>&1&
+       ./3-args_client 127.0.0.1 12345                               >> $@ 2>&1
+       sleep 1
+       echo '$$ ./test_simulator platform.xml test.xml'              >> $@
+       ./3-args_simulator gtut-platform.xml 3-args.xml               >> $@ 2>&1
+       echo '$$'                                                     >> $@ 
+
+3-args_client 3-args_server 3-args_simulator: _3-args_client.c _3-args_server.c _3-args_simulator.c
+       make -f 3-args.mk
+
+_3-args_client.c _3-args_server.c _3-args_simulator.c: 3-args.c test.xml
+       ../../tools/gras/gras_stub_generator 3-args test.xml >/dev/null
+
+clean::
+       if [ -e 3-args.mk ] ; then make -f 3-args.mk clean; fi
+       rm -f _3-args_client.c _3-args_server.c _3-args_simulator.c 3-args.trace 3-args.mk
+