도메인 목록을 핑 (1000 - 10000 사이)하고 내 앱의 온라인 수와 오프라인 수를 계산하십시오. 내가 겪고있는 문제는 Timeout 시스템의 IP 주소 목록을 만들고 싶습니다. 그렇게 할 수있는 방법이 있습니까?TimedOut에서 IP 가져 오기 Pingreply
public async void PingCompletedMethod(object sender, PingCompletedEventArgs e)
{
// Sorts results of ping process
PingReply rep = e.Reply;
try
{
if (e.Error != null)
{
// Counts number of unreachable endpoints
errorPings++;
ErrorPing.Text = Convert.ToString(errorPings);
ErrorPing.Background = Brushes.OrangeRed;
}
else
{
// Counts Pings that were succesfull
successPings++;
SuccessPing.Text = Convert.ToString(successPings);
}
// Counts Online/Offline responses
if (rep.Status == IPStatus.Success)
{
regOnline++;
onlineResult.Text = Convert.ToString(regOnline) + " Endpoints Online";
onlineResult.Background = Brushes.LightGreen;
}
else if (rep.Status == IPStatus.TimedOut)
{
// exportList.Add(Convert.ToString(rep.Address));
regOffline++;
offlineResult.Text = Convert.ToString(regOffline) + " Endpoints Offline";
offlineResult.Background = Brushes.Orange;
}
}
catch (Exception ex)
{
regOffline++;
}
TimedOut 루프 아래에서 rep.Address를 가져 오려고하면 각 항목마다 0.0.0.0을 얻습니다. Success 루프에 추가 된 것과 동일한 경우 IP를 얻습니다. TimedOut 핑의 IP 또는 도메인 이름을 얻고 싶습니다. 미리 피터
foreach (string regOne in regOneList)
{
System.Threading.AutoResetEvent autores = new System.Threading.AutoResetEvent(false);
Ping pingasync = new Ping();
pingasync.PingCompleted += new PingCompletedEventHandler(PingCompletedMethod);
pingasync.SendAsync(regOne, 1000);
autores.WaitOne(1);
}
감사 :
여기 핑입니다.
근무 해 주셔서 감사합니다. (타임 아웃 팁에도 감사드립니다)! –
나는 이것을 다음과 같이 사용했다 :'exportList.Add (Convert.ToString (e.UserState);' –