annotate Paper/src/RemoteDGMQueue.cbc @ 10:7573c185aecf

add impl
author ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
date Tue, 25 Jan 2022 22:27:17 +0900
parents 25cf5b9b74a2
children 01b88c0dd337
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 __code sendDataRemoteDGMQueue(struct RemoteDGMQueue* cQueue, union Data* data, __code next(...), __code whenError(...)){
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 char recv_buf;
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 int send_size, recv_size;
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 send_size = send(cQueue->socket, data, sizeof(union Data), 0);
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 if (send_size == -1) {
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 printf("send error\n");
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 close(cQueue->socket);
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 goto whenError();
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 }
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 recv_size = recv(cQueue->socket, &recv_buf, 1, 0);
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 if (recv_size == -1) {
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 printf("recv error\n");
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 close(cQueue->socket);
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 goto whenError();
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 } else if (recv_size == 0) {
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 printf("connection ended\n");
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 close(cQueue->socket);
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 goto whenError();
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 } else if(recv_buf == 0) {
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 printf("Finish connection\n");
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 close(cQueue->socket);
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 goto whenError();
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 }
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 goto next(...);
25cf5b9b74a2 add GearsDGM
ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 }