We help IT Professionals succeed at work.

Revealing the IP and NetBios Names !!

dineth
dineth asked
on
Hello Experts !!

I have developed a chat server using MFC. I'm using a class called "CClientSocket" which is a subclass of CSocket to accept all client calls.
In order to keep in track of clients I add each ClientSocket object in to a list.

I want to know whether, there is a way to get all the clients IP Addresses and NetBios Names programmatically.

ThankX.. !!
--Din--
Comment
Watch Question

Commented:
NetBios names have no context here since CSocket and any classes derived from it are strictly TCPIP.

But if you really mean "IP addresses and DNS hostnames" then the answer is:

1) Use CAsyncSocket::GetPeerName() to get the IP ADDRESS of the host at the other end of the connection.

2) Use gethostbyaddr() do lookup the IP from #1 using DNS to try and resolve the hostname.  Be aware, however, that not all hosts that you may be connected to have a hostname that can be resolved.  So this may fail....

Author

Commented:
Thanks a lot ...!!

--Din--

Commented:
Do you need more help on this question?

If so, what?

If not, please close this question by accepting the comment as an answer...

Explore More ContentExplore courses, solutions, and other research materials related to this topic.