zoukankan      html  css  js  c++  java
  • TCP编程(1):获得IP地址及域名

    /*--===------------------------------------------===---
    测试DNS类,实现IP地址和域名之间的转换

                许明会    12:25:29 2007年12月9日
    --===------------------------------------------===---
    */
    using System;
    using System.Net; //引入Net空间

    namespace xumh
    {
        
    public class myClass
        {
        };

        
    public class runMyApp
        {
            
    static void Main()
            {
                
    string strLocalHost=Dns.GetHostName();
                IPHostEntry he 
    = Dns.GetHostEntry(strLocalHost);
                Console.Write(
    "本机主机名称为{0},IP地址为{1}",
                    strLocalHost, he.AddressList[
    0].ToString());
                
    //根据IP地址得到域名
                Console.WriteLine("请输入IP地址,得到其域名:");
                
    string strIP = Console.ReadLine();
                he 
    = Dns.GetHostEntry(strIP);
                Console.WriteLine(
    "{0},{1}",strIP,he.HostName);
                
    //根据域名得到IP地址
                Console.Write("请输入域名,得到其IP地址:");
                
    string strDomain = Console.ReadLine();
                he 
    = Dns.GetHostEntry(strDomain);
                Console.WriteLine(
    "{0},{1}",strDomain,he.AddressList[0].ToString());

            }
        };
    }
  • 相关阅读:
    ZOJ-2008-Invitation Cards(dijkstra)
    codeforce-191E-Thwarting Demonstrations(树状数组+二分+离散)
    hdu-4612-Warm up(边双连通分量--有重边)
    TypeError: only integer scalar arrays can be converted to a scalar index
    电脑开机黑屏解决方法
    python中list与数组
    cv2.line()函数
    python中的浅拷贝与深拷贝——copy()
    pycharm中使用cv2模块
    numpy.where用法
  • 原文地址:https://www.cnblogs.com/flaaash/p/988741.html
Copyright © 2011-2022 走看看