summaryrefslogtreecommitdiff
path: root/Year_3/TSDWL
diff options
context:
space:
mode:
Diffstat (limited to 'Year_3/TSDWL')
-rw-r--r--Year_3/TSDWL/webserver/server.c5
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);