try opening socket twice

pull/118/head
alanbjohnston 5 years ago committed by GitHub
parent b5fc6e09cb
commit 481a1fee94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1577,7 +1577,32 @@ void get_tlm_fox() {
printf("\nConnection Failed \n");
printf("Error: %s \n", strerror(errno));
error = 1;
sleep(2.0); // sleep if socket connection refused
sleep(1.0); // sleep if socket connection refused
// try again
error = 0;
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
printf("\n Socket creation error \n");
error = 1;
}
memset( & serv_addr, '0', sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(PORT);
// Convert IPv4 and IPv6 addresses from text to binary form
if (inet_pton(AF_INET, "127.0.0.1", & serv_addr.sin_addr) <= 0) {
printf("\nInvalid address/ Address not supported \n");
error = 1;
}
if (connect(sock, (struct sockaddr * ) & serv_addr, sizeof(serv_addr)) < 0) {
printf("\nConnection Failed \n");
printf("Error: %s \n", strerror(errno));
error = 1;
sleep(1.0); // sleep if socket connection refused
}
}
if (error == 1)
; //rpitxStatus = -1;

Loading…
Cancel
Save

Powered by TurnKey Linux.