view Paper/src/LocalDGMQueue.cbc @ 33:c1323b737cfd

...
author matac42 <matac@cr.ie.u-ryukyu.ac.jp>
date Thu, 18 Jan 2024 19:37:19 +0900
parents c8151a82f313
children
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 whenError(...);
    }
    if (recv_size == 0) {
        printf("connection ended\n");
        goto whenError(...);
    }


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