Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 161
  • Last Modified:

Finding IP addresses


I was wondering, how could I get a list of the IP addresses of a machine (the program is running locally).

I need to initialise two TcpListener threads on a machine with two network cards and at this point they are hardcoded...

I am looking for something equivalent to the old gethostbyname from winsock...

Any ideas?

1 Solution
refer following artilces they will help you to retrieve IP address settings on your machine properly :

http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_21924111.html <==

http://www.codeproject.com/internet/my_ip_-_v2.asp <== Getting Addresses IP informations

http://www.codeproject.com/internet/bsipconfig.asp <== Review of the network adapter parameters..retrieve adapters settings

http://www.codeproject.com/internet/netcfg.asp <==  The "New ipconfig" and the IP Helper API.. another adapter info retriveal src

http://www.codeproject.com/internet/getipnr.asp <== Get all IP numbers of your machine (latest psdk required)

bluedog666Author Commented:
I guess I was not specific... I was looking for a .net answer WinSock i knew

Ont he other hnd, if this ill help anyone I managed to find what I was looking for....

      System::String^ hostName = Dns::GetHostName();
      Console::WriteLine( "SERVER -> Computer name : {0}", hostName );
      array<IPAddress^>^  ips;
      ips = Dns::GetHostAddresses (hostName);

      array<unsigned char>^ ip_address = gcnew array<unsigned char>(100);

      for(int i = 0; i < ips->Length; i++)
            Console::WriteLine("SERVER -> IP address: {0}", ips[i]->ToString());

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now