IPアドレスからホスト名を取得する

ホスト名からIPアドレスを取得するには
System.Net.DnsクラスのGetHostEntry関数を使います。

    // IPアドレス
    string IPaddress = "123.123.123.123";

    // IPHostEntry取得
    System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostEntry(IPaddress);

    // ホスト名を取得
    string hostname = hostEntry.HostName;

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)