keep alt = 0, reopen socket on failure, print error in open

pull/28/head
alanbjohnston 6 years ago committed by GitHub
parent 3a26bd7ee6
commit 6091c8be80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -900,6 +900,7 @@ int get_tlm_fox() {
if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
{
printf("\nConnection Failed \n");
printf("Error: %s \n", strerror(errno));
error = 1;
}
if (error == 1)
@ -914,9 +915,11 @@ int get_tlm_fox() {
printf("Sending buffer over socket!\n");
int sock_ret = send(sock, buffer[alt], buffSize, 0);
printf("Result of socket send: %d \n", sock_ret);
if (sock_ret == -1)
if (sock_ret == -1) {
printf("Error: %s \n", strerror(errno));
alt = (++alt) % 2;
socket_open = 0;
}
// alt = (++alt) % 2;
printf("Alternate value is %d \n", alt);
}
digitalWrite (0, HIGH);

Loading…
Cancel
Save

Powered by TurnKey Linux.