Please remove line 55 from your code.
you do not print the client address. It is like the variable name implies the server address.
To get the client address use
remove this line?
getsockname(ListeningSocket, (SOCKADDR *)&ServerAddr, (int *)sizeof(ServerAddr));
what should be in the () of getpeername?
yes sorry that line should not be there
i have used getpeername already in the code:
getpeername(NewConnection, (SOCKADDR *)&SenderInfo, &nlen);
printf("Server: Sending IP used: %s\n", inet_ntoa(SenderInfo.sin_addr));
printf("Server: Sending port used: %d\n", htons(SenderInfo.sin_port));
but i thought this was the servers ip and port?
so why is the client's ip showing as 0.0.0.0?
Last edited on