Mercurial > hg > Members > e085722 > Cerium
comparison Renderer/Test/test_linda.cc @ 0:04e28d8d3c6f
first commit
author | Daiki KINJYO <e085722@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Nov 2010 01:23:25 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:04e28d8d3c6f |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include "lindaapi.h" | |
4 #include "aquarium.pb.h" | |
5 | |
6 int main(int argc, char *argv[]) { | |
7 init_linda(); | |
8 srandom(time(0)); | |
9 aqua::Width *width = new aqua::Width(); | |
10 width->set_width(random() % 30); | |
11 printf("send: %d\n", width->width()); | |
12 int size = width->ByteSize(); | |
13 unsigned char *msg = (unsigned char *) malloc(sizeof(char) * size); | |
14 width->SerializeToArray(msg, size); | |
15 | |
16 int linda = open_linda_java("localhost", 10000); | |
17 int seq = psx_update(linda, 1, msg, size); | |
18 unsigned char *reply = NULL; | |
19 while (true) { | |
20 psx_sync_n(); | |
21 reply = psx_reply(seq); | |
22 if (reply != NULL) | |
23 break; | |
24 } | |
25 int len = psx_get_datalength(reply); | |
26 if (len != 0) { | |
27 width->ParseFromArray(reply + LINDA_HEADER_SIZE, len); | |
28 printf("recv: %d\n", width->width()); | |
29 } | |
30 delete width; | |
31 | |
32 return 0; | |
33 } |