Ping 域 C#
尝试 ping 域名并查看是否收到响应代码以指示其是否已注册。从以下代码中获得持续的积极结果 - 有什么想法吗?
public static string Check(string keyword)
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
// Use the default Ttl value which is 128,
// but change the fragmentation behavior.
options.DontFragment = true;
// Create a buffer of 32 bytes of data to be transmitted.
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
PingReply reply = pingSender.Send(keyword, timeout, buffer, options);
if (reply.Status == IPStatus.Success)
{
return "found";
}
else
{
return "not found";
}
}
private void hunt_Click(object sender, EventArgs e)
{
string keyword = txtKeyword.Text;
txtOutput.Text = Check(keyword);
}
如有任何帮助,我们将不胜感激:-)
trying to ping a domain and see if i get a response code to get a indication if its registered. getting constant positive results from the following code - any ideas?
public static string Check(string keyword)
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
// Use the default Ttl value which is 128,
// but change the fragmentation behavior.
options.DontFragment = true;
// Create a buffer of 32 bytes of data to be transmitted.
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
PingReply reply = pingSender.Send(keyword, timeout, buffer, options);
if (reply.Status == IPStatus.Success)
{
return "found";
}
else
{
return "not found";
}
}
private void hunt_Click(object sender, EventArgs e)
{
string keyword = txtKeyword.Text;
txtOutput.Text = Check(keyword);
}
any help is appreciated :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿,我运行了这段代码,它可以工作,(输入磨损的 IP 或 DNS 时会抛出异常)为什么不使用这个重载?
hey i ran this code and it works, (exception is thrown when worng IP or DNS is entered) why not use this overload?