日本好好热aⅴ|国产99视频精品免费观看|日本成人aV在线|久热香蕉国产在线

  • <cite id="ikgdy"><table id="ikgdy"></table></cite>
    1. 西西軟件下載最安全的下載網(wǎng)站、值得信賴的軟件下載站!

      首頁(yè)編程開(kāi)發(fā)C#.NET → c#獲得服務(wù)器的外網(wǎng)ip、內(nèi)網(wǎng)ip

      c#獲得服務(wù)器的外網(wǎng)ip、內(nèi)網(wǎng)ip

      相關(guān)軟件相關(guān)文章發(fā)表評(píng)論 來(lái)源:西西整理時(shí)間:2012/12/6 11:08:16字體大。A-A+

      作者:玉開(kāi)Sir點(diǎn)擊:0次評(píng)論:0次標(biāo)簽: ip

      • 類型:音頻處理大小:1M語(yǔ)言:中文 評(píng)分:5.3
      • 標(biāo)簽:
      立即下載

      如下代碼可以獲得服務(wù)器所在內(nèi)網(wǎng)的內(nèi)網(wǎng)ip

      IPHostEntry host;
      string localIP = "?";
      host = Dns.GetHostEntry(Dns.GetHostName());
      foreach (IPAddress ip in host.AddressList)
      {
          if (ip.AddressFamily.ToString() == "InterNetwork")
          {
              localIP = ip.ToString();
              break;
          }
      }
      return localIP;

      如果要獲得服務(wù)器的公網(wǎng)ip,可以使用下面代碼

      public string GetPublicIP()
      {
          String direction = "";
          WebRequest request = WebRequest.Create("http://checkip.dyndns.org/");
          using (WebResponse response = request.GetResponse())
          using (StreamReader stream = new StreamReader(response.GetResponseStream()))
          {
              direction = stream.ReadToEnd();
          }
      
          //Search for the ip in the html
          int first = direction.IndexOf("Address: ") + 9;
          int last = direction.LastIndexOf("</body>");
          direction = direction.Substring(first, last - first);
      
          return direction;
      }

        相關(guān)評(píng)論

        閱讀本文后您有什么感想? 已有人給出評(píng)價(jià)!

        • 8 喜歡喜歡
        • 3 頂
        • 1 難過(guò)難過(guò)
        • 5 囧
        • 3 圍觀圍觀
        • 2 無(wú)聊無(wú)聊

        熱門評(píng)論

        最新評(píng)論

        發(fā)表評(píng)論 查看所有評(píng)論(0)

        昵稱:
        表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
        字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過(guò)審核才能顯示)