Click to See Complete Forum and Search --> : Ip Adress


phijophilip
January 19th, 2005, 10:35 PM
can anytell tell how to get the IP address of a computer using vc++?

Andreas Masur
January 20th, 2005, 08:43 AM
[ Moved thread ]

Andreas Masur
January 20th, 2005, 08:44 AM
Take a look at the following FAQ (http://www.codeguru.com/forum/showthread.php?s=&threadid=233261)...

drewdaman
January 20th, 2005, 10:55 AM
you will probably need to store it in a sockaddr_in.... look here


SOCKADDR_IN serverInfo;
serverInfo.sin_family = AF_INET;
serverInfo.sin_addr.s_addr = INADDR_ANY; // Since this socket is listeningfor connections,
// any local address will do
serverInfo.sin_port = htons(nPort); // Convert integer 8888 tonetwork-byte order



basically, "INADDR_ANY" will give you the ip address.. play around with it to do what you want with it..


editing: sorry! i misread your post.. i thought you wanted to get the local ip address! but check out section 3.2 (and some of the stuff after that too...) at http://www.tutorialized.com/tutorial/Using-Internet-Sockets/456

ahoodin
January 20th, 2005, 02:44 PM
Can you expand on that? Do you want to use DNS? What?

ahoodin