8
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 __code sendDataRemoteDGMQueue(struct RemoteDGMQueue* cQueue, union Data* data, __code next(...), __code whenError(...)){
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 char recv_buf;
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 int send_size, recv_size;
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 send_size = send(cQueue->socket, data, sizeof(union Data), 0);
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 if (send_size == -1) {
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 printf("send error\n");
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 close(cQueue->socket);
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 goto whenError();
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 }
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 recv_size = recv(cQueue->socket, &recv_buf, 1, 0);
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 if (recv_size == -1) {
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 printf("recv error\n");
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 close(cQueue->socket);
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 goto whenError();
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 } else if (recv_size == 0) {
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 printf("connection ended\n");
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 close(cQueue->socket);
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 goto whenError();
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 } else if(recv_buf == 0) {
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 printf("Finish connection\n");
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 close(cQueue->socket);
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 goto whenError();
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 }
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 goto next(...);
|
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 }
|