diff --git a/sources/src/functions.c b/sources/src/functions.c index 6a01f1d7e9ef4bb1848e04c60c77bf69d9acd957..776afa2025888894be519e0db5db72a6f5b92d0e 100644 --- a/sources/src/functions.c +++ b/sources/src/functions.c @@ -212,38 +212,37 @@ void *readUdp(void *arg) timeout.tv_sec = 2; // 5 seconds timeout timeout.tv_usec = 0; - if (setsockopt(udp_sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) - { - perror("setsockopt failed"); - SHOULD_EXIT = 1; - return NULL; - } + // if (setsockopt(udp_sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) + // { + // perror("setsockopt failed"); + // SHOULD_EXIT = 1; + // return NULL; + // } for (;;) { - int bytes_read = (int)recvfrom(udp_sock, buffer, MAX_BUFFER_SIZE, 0, &recv_addr, &len); if (bytes_read > 0 && !isOwnIp(&recv_addr)) { - printf("Controller message recieved %s\n", bytes_read); + printf("Controller message recieved %d\n", bytes_read); processSmcp1Request(buffer, &recv_addr, bytes_read); } else if (bytes_read < 0) { - if (errno == EWOULDBLOCK || errno == EAGAIN) - { - // printf("recvfrom timeout, no data received.\n"); - } - else + // if (errno == EWOULDBLOCK || errno == EAGAIN) + // { + // // printf("recvfrom timeout, no data received.\n"); + // } + // else + // { + perror("recvfrom failed"); + if (PROXY_INIT_COMPLETE) { - perror("recvfrom failed"); - if (PROXY_INIT_COMPLETE) - { - printf("ERROR : UDP-SOCKET COMMUNICATION FAILED, CLOSING PROGRAM\n"); - SHOULD_EXIT = 1; - break; - } + printf("ERROR : UDP-SOCKET COMMUNICATION FAILED, CLOSING PROGRAM\n"); + SHOULD_EXIT = 1; + break; } + // } } if (SHOULD_EXIT && PROXY_INIT_COMPLETE)