+bool wait_socket_recv(int fd) {
+ fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+
+ struct timeval tv = {.tv_sec = 5};
+
+ if(select(fd + 1, &fds, NULL, NULL, &tv) != 1) {
+ fprintf(stderr, "Timed out waiting for the server to reply.\n");
+ return false;
+ }
+
+ return true;
+}
+