WinSock: How do I get the Host Name
-
I have written a Server Client Chat Program using CAsyncSocket. I can get the Remote Hosts I.P. Address using the GetPeerName() Function. I also want the Host Name. To do this I sent a message with the OnConnect() and OnAccept() functions. This only works intermittently and if I disconnect the Client Leaving the Server Listening and then re-connect it does not work at all. What is a better and more reliable way to do this?
-
I have written a Server Client Chat Program using CAsyncSocket. I can get the Remote Hosts I.P. Address using the GetPeerName() Function. I also want the Host Name. To do this I sent a message with the OnConnect() and OnAccept() functions. This only works intermittently and if I disconnect the Client Leaving the Server Listening and then re-connect it does not work at all. What is a better and more reliable way to do this?
getnameinfo (WinSock2) returns the hostname for a given IP-address (gethostbyaddr is simpler in usage, but deprecated)