Mercurial > hg > Papers > 2022 > ikki-master
diff Paper/src/LocalDGMQueue.cbc @ 8:25cf5b9b74a2
add GearsDGM
author | ichikitakahiro <e165713@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 22 Jan 2022 23:27:45 +0900 |
parents | |
children | cc4cb64f9af9 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/LocalDGMQueue.cbc Sat Jan 22 23:27:45 2022 +0900 @@ -0,0 +1,37 @@ +__code getDataLocalDGMQueue(struct LocalDGMQueue* cQueue, __code next(...), __code whenEOF(...), __code whenError(...)){ + int recv_size, send_size; + char recv_buf[BUF_SIZE], send_buf; + + union Data* recv_data; + recv_size = recv(cQueue->socket, recv_data, sizeof(union Data), 0); + if (recv_size == -1) { + printf("recv error\n"); + goto exit_code(); + } + if (recv_size == 0) { + printf("connection ended\n"); + } + + + FileString* fileString = NEW(FileString); + fileString = recv_data; + if (fileString->EoF) == 1) { + send_buf = 0; + send_size = send(cQueue->socket, &send_buf, 1, 0); + if (send_size == -1) { + printf("send error\n"); + } + close(cQueue->buffer); + goto whenEOF(...); + } else { + send_buf = 1; + send_size = send(cQueue->socket, &send_buf, 1, 0); + if (send_size == -1) { + printf("send error\n"); + goto whenError(...); + } + } + + Gearef(context, cQueue)->data = recv_data; + goto putLocalDGMQueue(recv_data, next); +}