adding ccs test program to examples.
authorSameer Kumar <skumar2@uiuc.edu>
Wed, 2 Feb 2005 16:51:26 +0000 (16:51 +0000)
committerSameer Kumar <skumar2@uiuc.edu>
Wed, 2 Feb 2005 16:51:26 +0000 (16:51 +0000)
examples/converse/ccstest/Makefile [new file with mode: 0644]
examples/converse/ccstest/Makefile.win32 [new file with mode: 0644]
examples/converse/ccstest/client.C [new file with mode: 0644]
examples/converse/ccstest/server.c [new file with mode: 0644]

diff --git a/examples/converse/ccstest/Makefile b/examples/converse/ccstest/Makefile
new file mode 100644 (file)
index 0000000..9d90b22
--- /dev/null
@@ -0,0 +1,19 @@
+CHARMDIR=../../..
+CHARMC=$(CHARMDIR)/bin/charmc $(OPTS)
+
+all: server client
+
+server: server.o
+       $(CHARMC) -o $@ server.o -language converse++ 
+
+client: client.o
+       $(CHARMC) -o $@ client.o -seq -language c++ -lccs-client
+
+server.o: server.c
+       $(CHARMC) -c server.c -language converse++
+
+client.o: client.C
+       $(CHARMC) -c client.C -seq -language c++ 
+
+clean:
+       rm -f client server *.o conv-host charmrun
diff --git a/examples/converse/ccstest/Makefile.win32 b/examples/converse/ccstest/Makefile.win32
new file mode 100644 (file)
index 0000000..4ed817f
--- /dev/null
@@ -0,0 +1,39 @@
+CHARMBIN=..\..\..\bin\r
+CPP = cl.exe\r
+\r
+INC = /I"..\..\..\include"\r
+\r
+CPP_PROJ=/nologo /MT /w /Gm /GX /ZI /Od $(INC)\\r
+ /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX\\r
+ /Fo /FD /c /GZ\r
+\r
+LINK=link.exe\r
+LINK_FLAGS = /nologo /LIBPATH:"..\..\..\lib" /nodefaultlib:"libc"\r
+LINK_OTHER = libldb-rand.obj libck.lib libconv-core.lib libtrace-none.lib libconv-cplus-y.lib ws2_32.lib kernel32.lib \r
+\r
+LINK_COTHER= /nologo ws2_32.lib\r
+\r
+SOBJS = server.obj\r
+COBJS = client.obj ccs.obj\r
+\r
+.SILENT:\r
+\r
+all: server client\r
+\r
+server: $(SOBJS)\r
+       $(LINK) $(LINK_FLAGS) $(LINK_OTHER) /out:"server.exe" $(SOBJS)\r
+       copy $(CHARMBIN)\conv-host.exe .\r
+\r
+client: $(COBJS)\r
+       $(LINK) $(LINK_COTHER) /out:"client.exe" $(COBJS)\r
+\r
+.c.obj: \r
+       $(CPP) $(CPP_PROJ) $<\r
+\r
+clean:\r
+       del *.decl.h\r
+       del *.def.h\r
+       del conv-host.exe\r
+       del *.obj\r
+       del pgm.exe\r
+       del vc60.*\r
diff --git a/examples/converse/ccstest/client.C b/examples/converse/ccstest/client.C
new file mode 100644 (file)
index 0000000..cd2ee9e
--- /dev/null
@@ -0,0 +1,40 @@
+#include "ccs-client.h"
+//#include "ccs-client.c"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void  usage(void)
+{
+  fprintf(stderr, "Usage: client svrIP svrPort\n");
+  exit(1);
+}
+
+main(int argc, char **argv)
+{
+  CcsServer svr;
+  CcsSec_secretKey *key=NULL,keySto;
+  int i;
+  char *sendWhat="milind";
+  char reply[1024];
+  if(argc < 3) {
+    usage();
+  }
+  if(argc>3 && CCS_AUTH_makeSecretKey(argv[3],&keySto))
+          key=&keySto;
+  
+  CcsConnect(&svr, argv[1], atoi(argv[2]), key);
+  for(i=0;i<CcsNumPes(&svr);i++) {
+    CcsSendRequest(&svr, "ping", i, strlen(sendWhat)+1, sendWhat);
+    CcsRecvResponse(&svr, 1023, reply,60);
+    printf("Reply: %s", reply);
+  }
+
+  for(i=0;i<CcsNumPes(&svr);i++) {
+    CcsSendRequest(&svr, "ping", i, strlen(sendWhat)+1, sendWhat);
+    CcsRecvResponse(&svr, 1023, reply,60);
+    printf("Reply: %s", reply);
+  }
+  exit(0);
+}
+
diff --git a/examples/converse/ccstest/server.c b/examples/converse/ccstest/server.c
new file mode 100644 (file)
index 0000000..9df363c
--- /dev/null
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include "converse.h"
+#include "conv-ccs.h"
+
+void handler(char *msg)
+{
+  if(CcsIsRemoteRequest()) {
+    char answer[1024];
+    char *name=msg+CmiMsgHeaderSizeBytes;
+    sprintf(answer, "hello %s from processor %d\n", name, CmiMyPe());
+    CmiPrintf("CCS Ping handler called on %d with '%s'.\n",CmiMyPe(),name);
+    CcsSendReply(strlen(answer)+1, answer);
+  }
+}
+
+void user_main(int argc, char **argv)
+{
+int i;
+  CcsRegisterHandler("ping2", handler);
+  CcsRegisterHandler("ping", handler);
+  CmiPrintf("CCS Handlers registered.  Waiting for net requests...\n");
+  
+}
+
+main(int argc, char **argv)
+{
+  ConverseInit(argc, argv, user_main, 0, 0);
+}