试图打造一个领域,看一看是否收到回复守则,以了解其登记情况。 从以下法典中不断取得积极成果——任何想法?
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);
}
感谢: