From b69d50c415ef1571bd42bb3eb1a1b3b38eab43dd Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 24 Jan 2022 19:32:57 +0100 Subject: fix server --- Year_3/TSDWL/webserver/server.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Year_3') diff --git a/Year_3/TSDWL/webserver/server.c b/Year_3/TSDWL/webserver/server.c index 823fea3..e7e2dad 100644 --- a/Year_3/TSDWL/webserver/server.c +++ b/Year_3/TSDWL/webserver/server.c @@ -112,11 +112,12 @@ read_headers(int* fd, char** headers, int* headers_num) i++; } - buffer[i - 1] = '\0'; if (i < 2) { break; } + buffer[i - 1] = '\0'; + memcpy(headers[*headers_num], buffer, i); (*headers_num)++; } @@ -341,7 +342,7 @@ main(int argc, char* argv[]) } get_client_ip(clientfd, client_ip); - printf("Connection from '%s':\n", client_ip); + printf("Connection from '%s:%d':\n", inet_ntoa(address.sin_addr), address.sin_port); read_headers(&clientfd, headers, &headers_num); -- cgit v1.2.3-18-g5258