Get remote host from server - sockets

Hi all!

I bring this time a programming question.

I am using Berkeley sockets under TCP protocol, I want to get in the server the hostname of the client that is connecting with me, this is:

server:
user@hostServer

client@
user@hostClient

Is there a function (I think maybe the accept fills the sockaddr_in structure passed as argument with this data but I don't know how to get the info I need) to get at serverHost the string: "hostClient" when this last one connects to the server?

Thanks!
 
You should able to get ip addr of client from sockaddr structure (which you give to accept() ), then resolve it via gethostbyaddr(3)
 
Back
Top