view Paper/src/LocalDGMQueue.cbc @ 10:7573c185aecf

add impl
author ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
date Tue, 25 Jan 2022 22:27:17 +0900
parents cc4cb64f9af9
children a3cda2aa18aa
line wrap: on
line source

__code getDataLocalDGMQueue(struct LocalDGMQueue* cQueue, __code next(...), __code whenEOF(...), __code whenError(...)){
    int recv_size, send_size;
    char 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 whenEOF(...);
    }
    if (recv_size == 0) {
        printf("connection ended\n");
        goto next(...);
    }


    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);
}