| 54 | } |
| 55 | |
| 56 | void start_client(void) { |
| 57 | if (client_fd >= 0) close(client_fd); |
| 58 | client_fd = socket(AF_INET, SOCK_STREAM, 0); |
| 59 | assert(client_fd >= 0); |
| 60 | set_nonblocking(client_fd); |
| 61 | connected = false; |
| 62 | ping_sent = false; |
| 63 | int r = connect(client_fd, (struct sockaddr*)&dest, sizeof(dest)); |
| 64 | assert((r == 0 || errno == EINPROGRESS) && "connect"); |
| 65 | } |
| 66 | |
| 67 | void main_loop(void) { |
| 68 | fd_set fdr, fdw; |