view Paper/src/RemoteDGMQueue.cbc @ 9:cc4cb64f9af9

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

__code sendDataRemoteDGMQueue(struct RemoteDGMQueue* cQueue, union Data* data, __code next(...), __code whenError(...)){
    char recv_buf;
    int send_size, recv_size;

    send_size = send(cQueue->socket, data, sizeof(union Data), 0);
    if (send_size == -1) {
        printf("send error\n");
        close(cQueue->socket);
        goto whenError();
    }

    recv_size = recv(cQueue->socket, &recv_buf, 1, 0);
    if (recv_size == -1) {
        printf("recv error\n");
        close(cQueue->socket);
        goto whenError();
    } else if (recv_size == 0) {
        printf("connection ended\n");
        close(cQueue->socket);
        goto whenError();
    } else if(recv_buf == 0) {
        printf("Finish connection\n");
        close(cQueue->socket);
        goto whenError();
    }
    goto next(...);
}