• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Net.IPHostEntry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Net.IPHostEntry的典型用法代码示例。如果您正苦于以下问题:C# IPHostEntry类的具体用法?C# IPHostEntry怎么用?C# IPHostEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IPHostEntry类属于System.Net命名空间,在下文中一共展示了IPHostEntry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Delete

        public void Delete(IPHostEntry host, DirectoryInfo target)
        {
            var wqlQuery = new ObjectQuery(string.Format(@"SELECT * from Win32_Directory WHERE Name = '{0}'", target.Name));

            var managementClassEntry = _managementClassList.First(x => x.Item1 == _hostsList.IndexOf(host));
            ManagementObjectSearcher objectSearcher = new ManagementObjectSearcher(managementClassEntry.Item2.Scope, wqlQuery);
            ManagementObjectCollection directoryObjectsCollection = objectSearcher.Get();

            if (directoryObjectsCollection.Count == 0)
            {
                throw new FileSystemInstrumentationException(@"{0} {1}.", ExceptionMessages.Win32_DirectoryFail, target.Name);
            }

            foreach (ManagementObject shareObject in directoryObjectsCollection)
            {
                PropertyDataCollection outParams;
                long returnValue;

                managementClassEntry.Item3.Handle("Delete", new List<PropertyDataObject>(), out outParams);

                returnValue = long.Parse(outParams["ReturnValue"].Value.ToString());

                if (returnValue != 0)
                {
                    throw new FileSystemInstrumentationException(@"{0} {1}.", ExceptionMessages.Win32_DirectoryFail, _errorMessageProvider.GetErrorMessage(ErrorMessageProvider.ErrorClass.Win32_Directory, returnValue));
                }
            }
        }
开发者ID:danni95,项目名称:Core,代码行数:28,代码来源:FileSystemInstrumentation.cs


示例2: GetManagementClass

        public ManagementClass GetManagementClass(string scopeString, string classString, IPHostEntry hostEntry, string username, string password)
        {
            SetHost(hostEntry);
            ValidateHost();

            var connectionOptions = new ConnectionOptions()
            {
                Impersonation = ImpersonationLevel.Impersonate,
                EnablePrivileges = true,
                Username = username,
                Password = password
            };

            var managementScope = new ManagementScope(String.Format(@"\\{0}\{1}", _host, scopeString), connectionOptions);
            var managementClass = new ManagementClass(managementScope, new ManagementPath(classString), new ObjectGetOptions());

            managementScope.Connect();

            if (!managementScope.IsConnected)
            {
                throw new InstrumentationException(ExceptionMessages.ScopeConnectFail);
            }

            return managementClass;
        }
开发者ID:danni95,项目名称:Core,代码行数:25,代码来源:ManagementClassFactory.cs


示例3: HostNameCompletedEventArgs

 public HostNameCompletedEventArgs( IPAddress ipAddress, IPHostEntry hostEntry )
 {
     if( ipAddress == null ) throw new NullReferenceException( "ipAddress" );
     if( hostEntry == null ) throw new NullReferenceException( "hostEntry" );
     _ipAddress = ipAddress;
     _hostEntry = hostEntry;
 }
开发者ID:LudovicT,项目名称:Grid-Mapper,代码行数:7,代码来源:ReverseDnsResolver.cs


示例4: SetHostName

 private void SetHostName(IPHostEntry host)
 {
     if (ListView != null && ListView.InvokeRequired)
         ListView.Invoke(new SetHostNameDelegate(SetHostName), host);
     else if (host != null && !host.HostName.Equals(SubItems[0].Text))
         Hostname = host.HostName;
 }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:7,代码来源:PeerListViewItem.cs


示例5: GetEndPoint

 private IPEndPoint GetEndPoint(string address, int port)
 {
     var host = new IPHostEntry();
     host.HostName = address;
     var ipAddress = Dns.GetHostAddresses(address).First();
     return new IPEndPoint(ipAddress, port);
 }
开发者ID:jcowart,项目名称:Symbiote,代码行数:7,代码来源:DefaultMemcachedConfiguration.cs


示例6: GetHostEndPoint

 internal IPEndPoint GetHostEndPoint()
 {
     lock (this)
     {
         if (_host == null || ServicePointManager.DnsRefreshTimeout >= 0 && (DateTime.Now - _lastUpdateTime).TotalMilliseconds > ServicePointManager.DnsRefreshTimeout)
         {
             var uriHost = _uri.Host;
             if (_uri.HostNameType == UriHostNameType.IPv6 || _uri.HostNameType == UriHostNameType.IPv4)
             {
                 if (_uri.HostNameType == UriHostNameType.IPv6)
                 {
                     // Remove square brackets
                     uriHost = uriHost.Substring(1, uriHost.Length - 2);
                 }
                 _host = new IPHostEntry();
                 _host.AddressList = new IPAddress[] { IPAddress.Parse(uriHost) };
             }
             else
             {
                 _host = Dns.GetHostEntry(uriHost);
             }
             _lastUpdateTime = DateTime.Now;
         }
         var index = ServicePointManager.EnableDnsRoundRobin ? ((uint)_index++ % _host.AddressList.Length) : _index;
         return new IPEndPoint(_host.AddressList[index], _uri.Scheme == Uri.UriSchemeHttps ? (_uri.IsDefaultPort ? 443 : _uri.Port) : _uri.Port);
     }
 }
开发者ID:llenroc,项目名称:HttpClient,代码行数:27,代码来源:DnsResolverHelper.cs


示例7: hostent_to_IPHostEntry

		private static IPHostEntry hostent_to_IPHostEntry(string h_name, string[] h_aliases, string[] h_addrlist) 
		{
			IPHostEntry he = new IPHostEntry();
			ArrayList addrlist = new ArrayList();

			he.HostName = h_name;
			he.Aliases = h_aliases;
			for(int i=0; i<h_addrlist.Length; i++) {
				try {
					IPAddress newAddress = IPAddress.Parse(h_addrlist[i]);

					if( (Socket.SupportsIPv6 && newAddress.AddressFamily == AddressFamily.InterNetworkV6) ||
					    (Socket.SupportsIPv4 && newAddress.AddressFamily == AddressFamily.InterNetwork) )
						addrlist.Add(newAddress);
				} catch (ArgumentNullException) {
					/* Ignore this, as the
					 * internal call might have
					 * left some blank entries at
					 * the end of the array
					 */
				}
			}

			if(addrlist.Count == 0)
				throw new SocketException(11001);

			he.AddressList = addrlist.ToArray(typeof(IPAddress)) as IPAddress[];
			return he;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:Dns_2_1.cs


示例8: GetLocalHost

		static void GetLocalHost (SimpleResolverEventArgs args)
		{
			//FIXME
			IPHostEntry entry = new IPHostEntry ();
			entry.HostName = "localhost";
			entry.Aliases = EmptyStrings;
			args.ResolverError = 0;
			args.HostEntry = entry;

			bool ipv4 = Socket.OSSupportsIPv4;
			bool ipv6 = Socket.OSSupportsIPv6;
			List<IPAddress> ips = new List<IPAddress> ();
			if (ipv4)
				ips.Add (IPAddress.Loopback);
			if (ipv6)
				ips.Add (IPAddress.IPv6Loopback);

			foreach (NetworkInterface iface in NetworkInterface.GetAllNetworkInterfaces ()) {
				if (NetworkInterfaceType.Loopback == iface.NetworkInterfaceType)
					continue;

				foreach (UnicastIPAddressInformation info in iface.GetIPProperties ().UnicastAddresses) {
					IPAddress addr = info.Address;
					AddressFamily family = addr.AddressFamily;
					if ((ipv6 && AddressFamily.InterNetworkV6 == family) ||
						(ipv4 && AddressFamily.InterNetwork == family)) {
						ips.Add (addr);
					}
				}
			}
			entry.AddressList = ips.ToArray ();
		}
开发者ID:netngn,项目名称:Mono.Dns,代码行数:32,代码来源:SimpleResolver.cs


示例9: GetLocalHost

		void GetLocalHost (SimpleResolverEventArgs args)
		{
			//FIXME
			IPHostEntry entry = new IPHostEntry ();
			entry.HostName = "localhost";
			entry.AddressList = new IPAddress [] { IPAddress.Loopback };
			entry.Aliases = EmptyStrings;
			args.ResolverError = 0;
			args.HostEntry = entry;
			return;

/*
			List<IPEndPoint> eps = new List<IPEndPoint> ();
			foreach (NetworkInterface iface in NetworkInterface.GetAllNetworkInterfaces ()) {
				if (NetworkInterfaceType.Loopback == iface.NetworkInterfaceType)
					continue;

				foreach (IPAddress addr in iface.GetIPProperties ().DnsAddresses) {
					if (AddressFamily.InterNetworkV6 == addr.AddressFamily)
						continue;
					IPEndPoint ep = new IPEndPoint (addr, 53);
					if (eps.Contains (ep))
						continue;

					eps.Add (ep);
				}
			}
			endpoints = eps.ToArray ();
*/
		}
开发者ID:westybsa,项目名称:mono,代码行数:30,代码来源:SimpleResolver.cs


示例10: Connect

 /// <summary>
 /// Connect to Server:Port
 /// </summary>
 public void Connect(IPHostEntry ip, Int32 Port)
 {
     foreach (IPAddress addr in ip.AddressList)
     {
         this.Connect(addr, Port);
     }
 }
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:10,代码来源:CSocket.cs


示例11: StartListening

        public void StartListening()
        {
            byte[] bytes = new Byte[BufferSize];

            IPHostEntry ipHostInfo = new IPHostEntry();
            ipHostInfo.AddressList = new IPAddress[] { _serverIP};
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            IPEndPoint remoteEndPoint = new IPEndPoint(ipAddress, port);
            // Create a TCP/IP socket.
            Socket listener = new Socket(AddressFamily.InterNetwork,
                SocketType.Stream, ProtocolType.Tcp);

            try
            {
                listener.BeginConnect(remoteEndPoint, new AsyncCallback(ConnectCallback), listener);
                connectDone.WaitOne();

                // receive data
                receiveDone.Reset();
                Receive(listener);
                receiveDone.WaitOne();

                Console.WriteLine("Disconnecting from feed");

                listener.Shutdown(SocketShutdown.Both);
                listener.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Feed Error " + e.ToString());
            }
        }
开发者ID:vmartinrdi,项目名称:NMEAServerExample,代码行数:32,代码来源:NMEAFeed.cs


示例12: NetworkDictionaryItem

 internal NetworkDictionaryItem( IPAddress ipAddress, PingReply pingReply, PhysicalAddress macAddress, IPHostEntry hostEntry, IOS os )
 {
     _ipAddress = ipAddress;
     _pingReply = pingReply;
     _macAddress = macAddress;
     _hostEntry = hostEntry;
     _os = os;
     _ports = new ConcurrentDictionary<ushort,ushort>();
 }
开发者ID:LudovicT,项目名称:Grid-Mapper,代码行数:9,代码来源:NetworkDictionaryItem.cs


示例13: Lookup

 public IPHostEntry Lookup(string address)
 {
     IPHostEntry hostEntry = new IPHostEntry();
     try {
         IPAddress hostIPAddress = IPAddress.Parse(address);
         hostEntry = Dns.GetHostEntry(hostIPAddress);
     } catch { }
     return hostEntry;
 }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:9,代码来源:IPtoDNS.cs


示例14: GetHostEntry

		private IPHostEntry GetHostEntry(string hostname) {
			IPAddress address;
			if (IPAddress.TryParse(hostname, out address)) {
				IPHostEntry entry = new IPHostEntry();
				entry.AddressList = new IPAddress[] { address };
				return entry;
			}
			return Dns.GetHostEntry(hostname);
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:9,代码来源:StreamCreator.cs


示例15: Startscan

        public void Startscan(Object state)
        {
            string ip = state.ToString();
            int list = 0;
            threadnum++;
            if (endscan == false)
            {
                    try
                    {
                        IPHostEntry HostA = new IPHostEntry();
                        HostA = Dns.Resolve(ip);
                        string ipt = HostA.HostName.ToString();

                        TcpClient tcp = new TcpClient();
                        tcp.Connect(ipt, int.Parse(textBox2.Text));

                        //list = portlist.Items.Add(port.ToString() + "端口开放" ,false);
                        MyInvoke mi = new MyInvoke(UpdateUIport);
                        this.BeginInvoke(mi, new object[] { ip + "开放" });
                        list = list + 1;

                    }
                    catch
                    {
                        //portlist1.Items.Add(port.ToString() + "端口无法连接");
                        MyInvoke mi = new MyInvoke(UpdateUI);
                        this.BeginInvoke(mi, new object[] { ip + "无法连接" });

                    }
                    finally
                    {
                        Thread.Sleep(0);
                        //loglist.Items.Add("结束线程" + port.ToString());
                        //委托调用
                        MyInvoke mi = new MyInvoke(UpdateUI2);
                        this.BeginInvoke(mi, new object[] { "结束线程" +ip });

                        asyncOpsAreDone.Close();
                        // label5.Text = portnum.ToString();

                        MyInvoke mi3 = new MyInvoke(UpdateUI3);
                        this.BeginInvoke(mi3, new object[] { list.ToString()});
                    }

            }

            if (endscan == true || ip==textBox1.Text)
            {
                // button1.Enabled = true;
                // button2.Enabled = false;
                asyncOpsAreDone.Close();
                MyInvoke mi4 = new MyInvoke(UpdateUI4);
                this.BeginInvoke(mi4, new object[] { "344" });

            }
        }
开发者ID:shijieru,项目名称:PortScanner,代码行数:56,代码来源:Form2.cs


示例16: SetHost

 private void SetHost(IPHostEntry hostEntry)
 {
     _host =
         hostEntry.AddressList == null || hostEntry.AddressList.FirstOrDefault() == null ?
             string.IsNullOrEmpty(hostEntry.HostName) ?
                 hostEntry.Aliases == null || string.IsNullOrEmpty(hostEntry.Aliases.FirstOrDefault()) ?
                     null : hostEntry.Aliases.FirstOrDefault()
             : hostEntry.HostName
         : hostEntry.AddressList.FirstOrDefault().MapToIPv6().ToString();
 }
开发者ID:danni95,项目名称:Core,代码行数:10,代码来源:ManagementClassFactory.cs


示例17: GetIPString

 public static string GetIPString(IPHostEntry iphostentry)
 {
     string IPString = "";
     string Divider = "";
     foreach (IPAddress IP in iphostentry.AddressList)
     {
         IPString += Divider + IP.ToString();
         Divider = ", ";
     }
     return IPString;
 }
开发者ID:cheynewallace,项目名称:pinger,代码行数:11,代码来源:Program.cs


示例18: alBuscarUsuarios

 protected ArrayList alBuscarUsuarios()
 {
     ipHostName = Dns.GetHostEntry(Dns.GetHostName());
     foreach (IPAddress ip in ipHostName.AddressList)
     {
         sQuery = "SELECT cuenta_usr, foto_usr FROM tabm_SGusuario T1 INNER JOIN tabt_SGsesion T2 ON T2.cod_usr = T1.cod_usr WHERE ipdir_usr= \"" + ip.ToString() + "\" LIMIT 6";
         if (bAbrirConexion())
         {
             try
             {
                 OdbcCommand ocComando = new OdbcCommand(sQuery, Conexion);
                 OdbcDataReader odcReader = ocComando.ExecuteReader();
                 while (odcReader.Read())
                 {
                     E_Usuario eUsuario = new E_Usuario();
                     eUsuario.Cuenta = odcReader[0].ToString();
                     eUsuario.ImagenBytes = (byte[])odcReader[1];
                     alResultados.Add(eUsuario);
                 }
                 vCerrarConexion();
             }
             catch (OdbcException ex)
             {
                 return null;
             }
         }
     }
     return alResultados;
 }
开发者ID:EbricenterOrg,项目名称:Seguridad,代码行数:29,代码来源:D_DatoInicioSesion.cs


示例19: BeginInvoke

		// Run the operation thread.
		public void BeginInvoke(String hostName)
				{
					try
					{
						switch(operation)
						{
							case DnsOperation.GetHostByName:
							{
								acceptResult = Dns.GetHostByName(hostName);
							}
							break;

							case DnsOperation.Resolve:
							{
								acceptResult = Dns.Resolve(hostName);
							}
							break;
						}
					}
					catch(Exception e)
					{
						// Save the exception to be thrown in EndXXX.
						exception = e;
					}
					completed = true;
					if(callback != null)
					{
						callback(this);
					}
				#if ECMA_COMPAT
					SocketMethods.WaitHandleSet(waitHandle);
				#else
					((ManualResetEvent)waitHandle).Set();
				#endif
				}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:36,代码来源:Dns.cs


示例20: bComprobarFuente

 public bool bComprobarFuente() 
 {
     sQuery = "SELECT cod_usr FROM tabm_sgusuario WHERE  ipdir_usr = '%.%.%.%' ";
     alResultados = csFunciones.alConsultar(sQuery);
     if (alResultados.Count == 0)
     {
         bool bBandera = false;
         ipHostName = Dns.GetHostEntry(Dns.GetHostName());
         foreach (IPAddress ip in ipHostName.AddressList)
         {
             sQuery = "SELECT cod_usr FROM tabm_sgusuario WHERE ipdir_usr = \"" + ip.ToString() + "\"";
             alResultados = csFunciones.alConsultar(sQuery);
             if (alResultados.Count != 0)
             {
                 bBandera = true;
                 break;
             }
             else
             {
                 bBandera = false;
             }     
         }
         if (bBandera == false) { MessageBox.Show("La dirección del equipo no corresponde con la cuenta", "Hotel San Carlos"); }
         return bBandera;
     }
     else 
     {
         return true;
     }
 }
开发者ID:EbricenterOrg,项目名称:Seguridad,代码行数:30,代码来源:D_DatoInicioSesion.cs



注:本文中的System.Net.IPHostEntry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Net.Interop类代码示例发布时间:2022-05-26
下一篇:
C# Net.IPEndPoint类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap