diff options
-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); |