public FrmCPS() { CpsNet = new cpsLIB.CpsNet(this); InitializeComponent(); string HostName = System.Net.Dns.GetHostName(); System.Net.IPHostEntry hostInfo = System.Net.Dns.GetHostEntry(HostName); label_host_name.Text = HostName; foreach (System.Net.IPAddress ip in hostInfo.AddressList) { comboBox_local_ips.Items.Add(ip.ToString()); } CpsNet.serverSTART(textBox_srv_port.Text); init_TimerUpdateGui(); TimerUpdateGui.Start(); listBox_frameLog.DataSource = ListFrames; textBox_MaxSYNCResendTrys.Text = CpsNet.MaxSYNCResendTrys.ToString(); textBox_WATCHDOG_WORK.Text = CpsNet.WATCHDOG_WORK.ToString(); checkBox_SendFramesCallback.Checked = CpsNet.SendFramesCallback; //checkBox_SendOnlyIfConnected.Checked = CpsNet.SendOnlyIfConnected; checkBox_send_big_endian.Checked = Frame._RemoteIsBigEndian; makeNewClient(); comboBox_listClients.SelectedIndex = 0; }
public void MailGonder(string HataMesaj, string HataDetay, string Baslik) { try { string URL = "smtp.gmail.com"; System.Net.IPHostEntry obj = System.Net.Dns.GetHostByName(URL); MailMessage MailMessage = new MailMessage(); MailMessage.From = new MailAddress("*****@*****.**", " ARES ", System.Text.Encoding.UTF8); SmtpClient SmtpClient = new SmtpClient(); MailMessage.Attachments.Add(new Attachment(Application.StartupPath + "\\ErrorScreen\\Aresv2HataEkran.jpg")); MailMessage.To.Add("*****@*****.**"); MailMessage.Subject = Baslik; MailMessage.IsBodyHtml = false; MailMessage.BodyEncoding = System.Text.Encoding.UTF8; MailMessage.Body = "ARES Programında Hata Meydana Geldi...Hata Kodu : " + HataMesaj + " Hata İçeriği : " + HataDetay + "\n"; MailMessage.Priority = MailPriority.High; SmtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "parola"); SmtpClient.Port = 587; SmtpClient.Host = "smtp.gmail.com"; SmtpClient.EnableSsl = true; SmtpClient.Send(MailMessage); } catch (Exception HATA) { } }
private void button4_Click(object sender, EventArgs e) { BravaConnection myConnection = new BravaConnection(); myConnection.BravaIP = System.Net.IPAddress.Parse(txtIPAddr.Text); myConnection.BravaPort = Int16.Parse(txtIPPort.Text); System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()); ConfigureAlertMessageRoute myConfigureAlertRouting = new ConfigureAlertMessageRoute((byte)numRouteRuleNum.Value, myIPs.AddressList[0], Int16.Parse(txtAlertPortNum.Text)); BravaSocket mySocket = new BravaSocket(myConfigureAlertRouting, myConnection); try { mySocket.OpenConnection(); mySocket.DoTransaction(); myConnection.rqStream.Close(); } catch (Exception) { mySocket.SocketClient.Close(); throw; } }
public System.Net.IPHostEntry GetHostEntry(string hostname) { System.Net.IPHostEntry hostEntries = new System.Net.IPHostEntry(); System.Net.IPAddress[] ipAddress; switch (hostname) { case "IPv4": ipAddress = new System.Net.IPAddress[] { System.Net.IPAddress.Parse("192.168.10.210"), System.Net.IPAddress.Parse("192.168.10.12") }; break; case "IPv6": ipAddress = new System.Net.IPAddress[] { System.Net.IPAddress.Parse("fe80::f487:4d2c:de32:bbc1%11"), System.Net.IPAddress.Parse("fe80::f798:4edc:d1b2:bbff%11") }; break; case "IPv46": ipAddress = new System.Net.IPAddress[] { System.Net.IPAddress.Parse("192.168.10.210"), System.Net.IPAddress.Parse("fe80::f798:4edc:d1b2:bbff%11") }; break; case "Empty": ipAddress = new System.Net.IPAddress[] { }; break; case "TimeOut": ipAddress = new System.Net.IPAddress[] { System.Net.IPAddress.Parse("0.0.0.0") }; break; default: throw new ArgumentException("Unable to resolve : " + hostname); } hostEntries.AddressList = ipAddress; return(hostEntries); }
public MainForm() { InitializeComponent(); if (!DesignMode) { try { System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("www.bing.com"); } catch { mapControl.Manager.Mode = AccessMode.CacheOnly; MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET - CloudsDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } mapControl.MapProvider = GMapProviders.BingSatelliteMap; mapControl.OnMapZoomChanged += mapControl_OnMapZoomChanged; mainOverlay = new GMapOverlay("top"); mapControl.Overlays.Add(mainOverlay); clouds = new GMapImage(gtl); clouds.Image = Resources.USOverlay; mainOverlay.Markers.Add(clouds); } }
public static string GetHostNameByIp(string ip) { ip = ip.Trim(); if (ip == string.Empty) { return(string.Empty); } try { // 是否 Ping 的通 if (Ping(ip)) { System.Net.IPHostEntry host = System.Net.Dns.GetHostEntry(ip); return(host.HostName); } else { return(ip); } } catch (Exception) { return(string.Empty); } }
public Map(List <Skola> Data) { this.Data = Data; InitializeComponent(); RefreshVocab(); try { System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("www.google.com"); } catch { MainMap.Manager.Mode = AccessMode.CacheOnly; MessageBox.Show( vocab.Error("downloadData"), vocab.map, MessageBoxButtons.OK, MessageBoxIcon.Warning ); } // config map MainMap.MapProvider = GMapProviders.OpenStreetMap; MainMap.Position = new PointLatLng(44.735027899515465, 20.533447265625); MainMap.MinZoom = 0; MainMap.MaxZoom = 24; MainMap.Zoom = 9; MainMap.OnMarkerClick += new MarkerClick(MainMap_OnMarkerClick); }
/// <summary> /// выбрали элемент /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedItems != null && listView1.SelectedItems.Count > 0) { DirectoryEntry entry = listView1.SelectedItems[0].Tag as DirectoryEntry; if (entry != null) { System.Net.IPHostEntry ip_host = System.Net.Dns.GetHostEntry(entry.Name); string myIP = string.Empty;// System.Net.Dns.GetHostByName(entry.Name).AddressList[0].ToString(); if (ip_host.AddressList != null && ip_host.AddressList.Length > 0) { foreach (System.Net.IPAddress ip_addr in ip_host.AddressList) { if (ip_addr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { myIP = ip_addr.ToString(); break; } } } if (myIP == string.Empty) { myIP = entry.Name; } textBoxTotalAddress.Text = string.Format("net.tcp://{0}:57000", myIP); } } }
//获取本机IP public static string GetIP() { System.Net.IPHostEntry ipe = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()); System.Net.IPAddress ipa = ipe.AddressList[1]; return(ipa.ToString()); }
public MainWindow() { InitializeComponent(); try { System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("www.google.com.hk"); } catch { mapControl.Manager.Mode = AccessMode.CacheOnly; MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET Demo", MessageBoxButton.OK, MessageBoxImage.Warning); } mapControl.MapProvider = GMapProviders.GoogleChinaMap; //google china 地图 mapControl.MinZoom = 2; //最小缩放 mapControl.MaxZoom = 17; //最大缩放 mapControl.Zoom = 5; //当前缩放 mapControl.ShowCenter = false; //不显示中心十字点 mapControl.DragButton = MouseButton.Left; //左键拖拽地图 mapControl.Position = new PointLatLng(32.064, 118.704); //地图中心位置:南京 mapControl.OnMapZoomChanged += new MapZoomChanged(mapControl_OnMapZoomChanged); mapControl.MouseLeftButtonDown += new MouseButtonEventHandler(mapControl_MouseLeftButtonDown); }
void updateStutes(bool value, DataTable mydt) //140604_2 //userName --> LoginName 140626 { //myInfo = mySQL.GetDataTable("select * from UserInfo where Username='******'", "Username"); try { DataRow[] myRows = mydt.Select(); if (myRows.Length == 1) { string hostname = System.Net.Dns.GetHostName(); //主机 System.Net.IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(hostname); //网卡IP地址集合 string IP6 = ipEntry.AddressList[0].ToString(); //取一个IP string IP4 = ipEntry.AddressList[ipEntry.AddressList.Length - 1].ToString(); //取一个IP myRows[0].BeginEdit(); //myRows[0]["ISLogin"] = value; myRows[0]["lastLoginONTime"] = DateTime.Now.ToString(); //140605_0 myRows[0]["lastComputerName"] = System.Environment.MachineName.ToString(); myRows[0]["lastIP"] = IP4; myRows[0].EndEdit(); mySQL.UpdateDataTable("select * from UserInfo where LoginName='" + this.txtUserID.Text.ToString() + "'", mydt, false); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void dns_resolve(string ip) { int cpt; string str; try { System.Net.IPHostEntry iphe = System.Net.Dns.Resolve(ip); str = "Name:\t" + iphe.HostName + "\r\n"; str += "Address:\r\n"; for (cpt = 0; cpt < iphe.AddressList.Length; cpt++) { str += "\t" + iphe.AddressList[cpt] + "\r\n"; } if (iphe.Aliases.Length > 0) { str += "Aliases:\r\n"; for (cpt = 0; cpt < iphe.Aliases.Length; cpt++) { str += "\t" + iphe.Aliases[cpt] + "\r\n"; } } this.textBox_telnet_add(str); } catch (Exception ex) { this.textBox_telnet_add(ex.Message); } }
/// <summary> /// Cria a stream para a uri informada. /// </summary> /// <param name="uri"></param> /// <returns></returns> public async Task <System.IO.Stream> CreateStream(Uri uri) { System.Net.Sockets.Socket socket = null; System.Net.IPAddress hostAddress; if (System.Net.IPAddress.TryParse(uri.Host, out hostAddress)) { socket = await Connect(hostAddress, uri.Port); if (socket.Connected) { return(await CreateStream(uri, socket)); } } System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostEntry(uri.Host); foreach (System.Net.IPAddress address in hostEntry.AddressList) { socket = await Connect(address, uri.Port); if (socket.Connected) { return(await CreateStream(uri, socket)); } } return(null); }
public string LokalIP() { //LokalIP bilgileri alınıyor string IPadresimiz = null; // Bir IPHostEntry örneğine; IP adresi veya host adını çözümler... // IPHostEntry - bir konteynır sınıfı internet host adres bilgilerini içerir. System.Net.IPHostEntry _IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()); // IPAddress sınıfı Bir IP ağı üzerinde bir bilgisayarın adresini içerir. foreach (System.Net.IPAddress LokalIPAddress in _IPHostEntry.AddressList) { // Soket son noktaya bağlandığında // InterNetwork IP'nin beklenen 4 adresini gösterir if (LokalIPAddress.AddressFamily.ToString() == "InterNetwork") { IPadresimiz = LokalIPAddress.ToString(); } } return(IPadresimiz); }
void ipScanProceed() { System.Net.IPHostEntry myHost = new System.Net.IPHostEntry(); int index = 0; try { myHost = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());//得到本地主机的DNS信息 //mw.debugBox.AppendText(myHost.HostName.ToString() + "\r\n");//显示本地主机名 //Debug_Event(this, myHost.HostName.ToString() + "\r\n"); lock (mw.dw.debugBox) mw.dw.debugBox.AppendText(myHost.HostName.ToString() + "\r\n"); for (int i = 0; i < myHost.AddressList.Length; i++)//显示本地主机的IP地址表 { if (myHost.AddressList[i].AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork) continue; //mw.debugBox.AppendText("Local Host IP->" + myHost.AddressList[i].ToString() + "\r\n"); //Debug_Event(this, "Local Host IP->" + myHost.AddressList[i].ToString() + "\r\n"); lock (mw.dw.debugBox) mw.dw.debugBox.AppendText("Local Host IP->" + myHost.AddressList[i].ToString() + "\r\n"); ipList.Insert(index++, myHost.AddressList[i].ToString()); } } catch (Exception error) { //System.Windows.MessageBox.Show(error.Message); lock (mw.dw.debugBox) mw.dw.debugBox.AppendText(error.Message + "\r\n"); } selectHost sh = new selectHost(this); sh.IPLIST = ipList;//Transmit candidate iplist to selectHost Window sh.pipe_Event += new selectHost.pipeevent_Handler((Object s,int _index) => { postbackIndex = _index; System.Threading.Thread thScan = new System.Threading.Thread(new System.Threading.ThreadStart(ipScanTarget)); thScan.IsBackground = true; thScan.Start(); }); sh.Show(); }
public string GetHostName() { string hName = ""; System.Net.IPHostEntry host = new System.Net.IPHostEntry(); host = System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]); //Split out the host name from the FQDN if (host.HostName.Contains(".")) { string[] sSplit = host.HostName.Split('.'); hName = sSplit[0].ToString(); } else { hName = host.HostName.ToString(); } return hName; }
public static string getHostName() { System.Net.IPHostEntry host = new System.Net.IPHostEntry(); host = System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]); strName = HttpContext.Current.Request.ServerVariables["REMOTE_USER"]; //strName = HttpContext.Current.Request.ServerVariables["AUTH_USER"]; //Split out the host name from the FQDN if (host.HostName.Contains(".")) { string[] sSplit = host.HostName.Split('.'); localMachine = sSplit[0].ToString(); } else { localMachine = host.HostName.ToString(); } return localMachine; }
/// <summary> /// ȡӲ�����к� /// </summary> /// <returns></returns> private string getVolumnSerial() { string serial; try { System.Management.ManagementObject disk = new System.Management.ManagementObject("win32_logicaldisk.deviceid=\"c:\""); disk.Get(); //ȡ������� System.Net.IPHostEntry myHost = new System.Net.IPHostEntry(); myHost = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()); string computername = myHost.HostName.ToString().Trim(); computername = ""; serial=disk.GetPropertyValue("VolumeSerialNumber").ToString(); return serial; } catch { return "24F779C7"; } }