🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.pl.comp.lang.csharp
Article #21817

Re: wybranie interfejsu sieciowego używanego do komunikacji z Internetem

#21817
From: WebSpider
Date: Sun, 31 Oct 2010 12:39
28 lines
2144 bytes
?Wymyśliłem coś takiego:

NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface adapter in adapters)
            {
                IPInterfaceProperties properties = 
adapter.GetIPProperties();
                foreach (GatewayIPAddressInformation GateWay in 
properties.GatewayAddresses)
                {
                    if (GateWay.Address.ToString() != "0.0.0.0")
                    {
                        foreach (IPAddressInformation uniCast in 
properties.UnicastAddresses)
                        {
                            if (uniCast.Address.AddressFamily == 
AddressFamily.InterNetwork)
                            {
                                                            lokalny = 
uniCast.Address;
                            }
                        }
                    }
                }
            }
na końcu zmienna lokalne otrzymuje adres IP interfejsu który ma ustawioną 
bramę,
niestety jeśli więcej niż jeden będzie miał bramę to sposób odpada. 
Technical Details
Message-ID: <iajo24$2u6c$1@news2.ipartners.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news2.ipartners.pl!not-for-mail
References: <ia9tld$16ur$1@news2.ipartners.pl> <4cc97d00$0$22808$65785112@news.neostrada.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news2.ipartners.pl!not-for-mail
From: "WebSpider" <webs1821@spaaamowe.gmail.com>
Newsgroups: alt.pl.comp.lang.csharp
Subject: Re: wybranie interfejsu sieciowego używanego do
 komunikacji z Internetem
Date: Sun, 31 Oct 2010 13:39:31 +0100
Organization: GTS Energis
Lines: 29
Message-ID: <iajo24$2u6c$1@news2.ipartners.pl>
References: <ia9tld$16ur$1@news2.ipartners.pl> <4cc97d00$0$22808$65785112@news.neostrada.pl>
NNTP-Posting-Host: ip-94-42-52-76.multimo.pl
Mime-Version: 1.0
X-Trace: news2.ipartners.pl 1288528772 96460 94.42.52.76 (31 Oct 2010 12:39:32 GMT)
X-Complaints-To: abuse@ipartners.pl
NNTP-Posting-Date: 31 Oct 2010 12:39:32 GMT
In-Reply-To: <4cc97d00$0$22808$65785112@news.neostrada.pl>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3502.922
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 15.4.3502.922
X-MSMail-Priority: Normal
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit