server not receiving ip address from client

please check out this question:
http://www.cplusplus.com/forum/beginner/95307/

i probably should have posted it in this forum
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 getpeername()
remove this line?
getsockname(ListeningSocket, (SOCKADDR *)&ServerAddr, (int *)sizeof(ServerAddr));

what should be in the () of getpeername?
remove this line?
No, look what you've posted in the other thread.

what should be in the () of getpeername?
See:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms738533%28v=vs.85%29.aspx
yes sorry that line should not be there

i have used getpeername already in the code:
1
2
3
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
Topic archived. No new replies allowed.