私のプログラムでは、ネットワーク内のすべてのアドレスをx.x.x.1からx.x.x.255にスキャン(ping)します。私はうまく動作するが、プログラムから実行に失敗したcmdでコマンドをテストしました。実行中にコマンドラインfor-loopを一時停止
私は自分のプログラムがウィンドウを作成できるように設定し、コマンドが終了してもそれを維持します。プロセスがしばらく働いて、x.x.x.1からx.x.x.18にpingして、それがつまってしまいます。私は手動でx.x.x.18にpingを試みてこのアドレスのための特別なものを見ました...まだ特別なものはありません。x.x.x.2からx.x.x.17までと同じ空いているアドレスです。
誰でも問題を診断できますか?ありがとうございました!
public void PingAllAddressInVirtualNetwork() {
string hotspotAddress = GetHotspotDefaultAddress();
string cmd = "/k \"for /l %i in (1,1,255) do ping " + hotspotAddress.Substring (0, hotspotAddress.Length - 1) + "%i -n 1 -w 15\"";
UnityEngine.Debug.Log ("cmd = "+cmd);
ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe", cmd);
processStartInfo.RedirectStandardOutput = true;
//processStartInfo.CreateNoWindow = true;
//processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.UseShellExecute = false;
processStartInfo.StandardOutputEncoding = Encoding.Default;
Process process = Process.Start (processStartInfo);
if (process != null) {
process.WaitForExit();
UnityEngine.Debug.Log ("ping address (scanning) finished.");
}
}
から次の255 IPにpingを実行します:なぜドン[System.Net.NetworkInformation.Ping](https://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping(v = vs.110).aspx)を使用していませんか? – Fildor
問題について:StandardErrorもリダイレクトできますか?そして、ReturnCodeが何であるか見てみてくださいが、ブロックするだけの方が便利だとは思っていません。 – Fildor