Listing Network adaptors question.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I've got two network adaptors in my computer(Windows server 2003).
One for public network such as internet, and the other for a private
network.
I mean, I want to connect other 2 PCs (XP Pro with SP3) to this adaptor and
create a private LAN.

Now I want to run my server application with the host IP of the
second(private
network) adaptor on the server PC( Windows server 2003).

I'm using Visual Studio.NET 2003 and C# for server applicaiton development.
Now, how can we list/scan all the available network adaptors and
corresponding
IP address using C#.

Kindly let me know.


Cheers,

Naveen.
 
Try this:

System.Management.SelectQuery sq = new
System.Management.SelectQuery("Win32_NetworkAdapterConfiguration",
"IPEnabled='TRUE'");

System.Management.ManagementObjectSearcher searcher = new
System.Management.ManagementObjectSearcher(sq);

foreach (System.Management.ManagementObject mos in searcher.Get())

{

MessageBox.Show(mos.GetPropertyValue("Caption").ToString());//Shows the
name

string[] obj = (string[])mos.GetPropertyValue("IPAddress");

foreach(string s in obj)

{

MessageBox.Show(s);

}

}



Look for Win32_NetworkAdapterConfiguration in SDK for a complete information
about your network adapters.
Hope that helps.
 
Is your server application running in IIS? If so, simply configure the site
to run on the IP address of the private network. No coding required.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Hi Nick,

Honestly speaking, I have no knowledge about IIS and
obviously, I don't know whether my application is
running in IIS or not.

Could you please let me know the starting point to know
more about IIS and also could you please let me know
how to configure IIS.

Cheers,

Naveen.
 
Hello Naveen,

I'm a bit surprised. You have a server based application that you are
connecting to IP addresses, so you must be a reasonably technical developer.
Yet you don't appear to have any familiarity with Internet Information
Server, the web/application server built in to every Windows Server OS.
Perhaps you simply weren't familiar with the acronym? (I apologize if my
use of the acronym was unclear in my previous post).

I am not aware of what your application is doing, or how you are planning to
accomplish your goal, so it is difficult to know if using IIS is feasable.
In addition, the fact that you are technical and have made headway running
your app without IIS leads me to believe that it may not be an effective use
of your time to refactor your app to use IIS or Web Services.

That said, if your app was constructed as an IIS HTTPHandler or an
HTTPModule, or even an ISAPI filter, then you could leverage IIS for
handling the port mapping.

HTH,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Back
Top