diff options
author | Santo Cariotti <santo@dcariotti.me> | 2022-01-24 19:32:57 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2022-01-24 19:32:57 +0100 |
commit | b69d50c415ef1571bd42bb3eb1a1b3b38eab43dd (patch) | |
tree | fda5adbd6aa94fa5d346c12c5ca9ce63728da14e /Year_3/TSDWL | |
parent | d43e1f5f5c0d70ca1b0ed4eed4b5364bf53e5685 (diff) |
fix server
Diffstat (limited to 'Year_3/TSDWL')
-rw-r--r-- | Year_3/TSDWL/webserver/server.c | 5 |
1 files changed, 3 insertions, 2 deletions
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); |