- if ((bytes = recv(in, buffer, CHUNKSIZE, 0)) < 1) {
- perror("recv");
- exit(EXIT_FAILURE);
+ if ((recvd = recv(in, buffer, CHUNKSIZE, 0)) < 1) {
+ /* TODO: Insert better connection-loss recovery here */
+ if ((in = (*open_fn)(url)) < 0) {
+ sleep(1);
+ continue;
+ }