By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,418 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,418 IT Pros & Developers. It's quick & easy.

Listing Network adaptors question.

P: n/a
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.

Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Try this:

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

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

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

{

MessageBox.Show(mos.GetPropertyValue("Caption").To String());//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.
Nov 16 '05 #2

P: n/a
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.
--
"Naveen Mukkelli" <Na************@discussions.microsoft.com> wrote in
message news:06**********************************@microsof t.com...
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.

Nov 16 '05 #3

P: n/a
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.

"Nick Malik [Microsoft]" wrote:
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.
--
"Naveen Mukkelli" <Na************@discussions.microsoft.com> wrote in
message news:06**********************************@microsof t.com...
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.


Nov 16 '05 #4

P: n/a
Hi Adrian,

Thanx for your response.
It works...

Cheers,

Naveen.

"Adrian" wrote:
Try this:

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

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

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

{

MessageBox.Show(mos.GetPropertyValue("Caption").To String());//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.

Nov 16 '05 #5

P: n/a
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.
--
"Naveen Mukkelli" <Na************@discussions.microsoft.com> wrote in
message news:F0**********************************@microsof t.com...
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.

"Nick Malik [Microsoft]" wrote:
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.
--
"Naveen Mukkelli" <Na************@discussions.microsoft.com> wrote in
message news:06**********************************@microsof t.com...
> 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.
>


Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.