diff --git a/main.c b/main.c index 1591e8d..d5933f2 100644 --- a/main.c +++ b/main.c @@ -482,6 +482,11 @@ static void on_accept(struct state *state, int accept_fd, interface_ref iface) { accept_fd); uint32_t header_be = 0; ssize_t header_received = read(accept_fd, &header_be, 4); + if (header_received == 0) { + // EOF according to man page of read. + fprintf(stderr, "Connection closed by peer (fd %d)\n", accept_fd); + goto done; + } if (header_received < 0) { perror("read[header]"); goto done; @@ -495,6 +500,7 @@ static void on_accept(struct state *state, int accept_fd, interface_ref iface) { } if (received == 0) { // EOF according to man page of read. + fprintf(stderr, "Connection closed by peer (fd %d)\n", accept_fd); goto done; } assert(received == header);