Revision 852969ee

View differences:

code/server/receive.c
27 27
// first unread byte in buffer
28 28
volatile int buffer_first = 0;
29 29
int server_sock;
30
int server_errors;
30 31

  
31 32
char *server_hostname;
32 33
char *ip_addr;
......
49 50
    }
50 51
    
51 52
    server_sock = 0;
53
    server_errors = 0;
52 54
    signal(SIGINT, sigint_handler);
53 55

  
54 56
    // resolve server hostname
......
72 74
    xbee_lib_init();
73 75
    while(1) {
74 76
    	listen_to_xbee();
77

  
78
        #ifdef USE_SERVER
79
        if (server_errors > SERVER_ERROR_THRESH) {
80
            close(server_socket);
81
            server_socket = socket_open();
82
            server_errors = 0;
83
        }
84
        #endif
75 85
    }
76 86
	return 0;
77 87
}
......
219 229
    //printf("sending to server\n");
220 230
    if (send(server_sock, send_buf, len+4, 0) != len+4) {
221 231
            printf("Mismatch in number of sent bytes");
232
            server_errors++;
222 233
            //close(server_sock);
223 234
            return;
224 235
    }

Also available in: Unified diff