using system;
using system.net;
using system.net.sockets;
namespace getipbydomain
{
/// <summary>
/// class1 的摘要说明。
/// </summary>
class class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[stathread]
static void main(string[] args)
{
//
// todo: 在此处添加代码以启动应用程序
//
if(args.length <= 0)
{
console.write("\ngetipbydomain v1.0 by ∮明天去要饭 qq:305725744\n");
console.write("usage:\n");
console.write(" getipbydomain.exe <domain>\n");
console.write("example:\n");
console.write(" getipbydomain.exe www.toempire.com");
}
else
{
string strdomain = args[0].tostring();
iphostentry hostentry = dns.resolve(strdomain);
ipendpoint ipendpoint = new ipendpoint( hostentry.addresslist[0],0);
//这就是你想要的
string ipaddress = ipendpoint.address.tostring();
console.write(ipaddress);
}
}
}
}
我只是简单的实现一下,有兴趣的朋友可以改改bug。