Mercurial > public > hey
changeset 8:f6e957bac68b
print client ip and port when connected
author | Dennis <dennisconcepcionmartin@gmail.com> |
---|---|
date | Tue, 18 Jul 2023 18:39:14 +0100 |
parents | fd1be990f66f |
children | ae1a84916424 |
files | src/main.c |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.c Tue Jul 18 18:29:46 2023 +0100 +++ b/src/main.c Tue Jul 18 18:39:14 2023 +0100 @@ -100,9 +100,9 @@ exit(1); } - struct IpPort ipport = get_ipport(servinfo->ai_addr); - printf("Server IP: %s\n", ipport.ipstr); - printf("Listening on port: %u\n", ipport.port); + struct IpPort server_ipport = get_ipport(servinfo->ai_addr); + printf("Server IP: %s\n", server_ipport.ipstr); + printf("Listening on port: %u\n", server_ipport.port); char send_buffer[100]; struct sockaddr_storage clientinfo; @@ -116,6 +116,10 @@ exit(1); } + struct IpPort client_ipport = get_ipport((struct sockaddr *)&clientinfo); + printf("Client IP: %s\n", client_ipport.ipstr); + printf("Client port: %u\n", client_ipport.port); + int pid = fork(); if (pid == 0) { // This is child @@ -136,3 +140,4 @@ return 0; } +