if you have a socket handle how can you know the IP of it in C or C++
Printable View
if you have a socket handle how can you know the IP of it in C or C++
sockaddr structure will hold all that information. Read up on it.
When you call the accept() function the second parameter (i think) is a pointer to a sockaddr structure to fill with the information regarding the connecting device.
-Dan
I think that he is referring to,"How can I, with just a socket handle, get the ip address"....Quote:
Originally Posted by codec
to be honest, I dont know, after looking through some unix man pages, I cannot find any function that will return the address of the other side of a socket.
Under Win32 platform, definitely. I am not familiar on the UNIX platform.
Kuphryn
getpeername() - Available on all platforms.