• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • 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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

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