# HG changeset patch # User Dennis # Date 1689701954 -3600 # Node ID f6e957bac68b54d6d79abd892461d36c874313f9 # Parent fd1be990f66f2d180eeb1b1a90bdcd2fbce0f24e print client ip and port when connected diff -r fd1be990f66f -r f6e957bac68b src/main.c --- 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; } +