×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Hello,
Am 02.01.2022 um 18:59 schrieb Patrik Schindler <poc@xxxxxxxxxx>:
Aside from creating a loop in my applications to simply try again to allocate a socket and sleep some seconds after failure, instead of just exiting — which other options can you recommend?
Thanks for all who responded with ideas.
I'll take the route described above. It seems to be the most clean one to me. A long sleep has the disadvantage to delay overall IPL time or at least the SBS start. Pinging localhost would be another approach, but just trying socket() with a 1 second sleep in between is done easier than an external ping, code-wise.
Code-Snippets for the interested:
Before:
if ( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
Qp0zLprintf("socket(): %s", strerror(errno));
exit(1);
}
After:
/* Keep trying to socket for 15 mins, so TCP/IP has enough time to start. */
for ( i = 0; i++; i <= 900 ) {
if ( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
sleep(1);
} else {
Qp0zLprintf("socket() succeeded after %d tries.\n", i);
break;
}
}
if ( i >= 900 ) {
Qp0zLprintf("Tried socket() %d times, giving up. Last error was %s.\n",
i, strerror(errno));
exit(1);
}
:wq! PoC
As an Amazon Associate we earn from qualifying purchases.