Article View: alt.pl.comp.lang.csharp
Article #21818Re: wybranie interfejsu sieciowego używanego do komunikacji z Internetem
From: 3P
Date: Sun, 31 Oct 2010 21:34
Date: Sun, 31 Oct 2010 21:34
33 lines
2205 bytes
2205 bytes
Dnia 31-10-2010 o 13:39:31 WebSpider <webs1821@spaaamowe.gmail.com>
napisał(a):
> ?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.
break; tam brakuje :)
Technical Details
Message-ID:
<op.vlgl7jwmmsp0fz@mcs>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.onet.pl!not-for-mailReferences:
<ia9tld$16ur$1@news2.ipartners.pl> <4cc97d00$0$22808$65785112@news.neostrada.pl> <iajo24$2u6c$1@news2.ipartners.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.onet.pl!not-for-mail From: 3P <nospam@serwer.pl> Newsgroups: alt.pl.comp.lang.csharp Subject: Re: wybranie interfejsu sieciowego używanego do komunikacji z Internetem Date: Sun, 31 Oct 2010 22:34:21 +0100 Organization: http://onet.pl Lines: 33 Message-ID: <op.vlgl7jwmmsp0fz@mcs> References: <ia9tld$16ur$1@news2.ipartners.pl> <4cc97d00$0$22808$65785112@news.neostrada.pl> <iajo24$2u6c$1@news2.ipartners.pl> NNTP-Posting-Host: 83.238.118.3 Mime-Version: 1.0 X-Trace: news.onet.pl 1288560913 19874 83.238.118.3 (31 Oct 2010 21:35:13 GMT) X-Complaints-To: niusy@onet.pl NNTP-Posting-Date: Sun, 31 Oct 2010 21:35:13 +0000 (UTC) User-Agent: Opera Mail/10.63 (Win32) X-Antivirus: avast! (VPS 101031-0, 2010-10-31), Outbound message X-Antivirus-Status: Clean Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit