どうすればよいですか?ソケットを閉じますか?私は問題を見ることができない、Googleは助けていない 何が原因でこのエラーが発生する可能性がありますか?これはSystem typeの例外です。 SocketError:既存の接続がリモートホストによって強制的に閉じられました
Console.WriteLine("Connection Recieved");
while (true)
{
var handler = socket.Accept();
try
{
while (handler.Connected)
{
var x = new byte[200000];
try
{
handler.Receive(x);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.InnerException);
Console.WriteLine(ex.StackTrace);
}
var command = new string(Encoding.UTF8.GetChars(x.Where(t => t != 0).ToArray()));
if (string.IsNullOrEmpty(command))
{
break;
}
var data = (Dictionary<string, object>)JsonConvert.DeserializeObject(command, (typeof(Dictionary<string, object>)));
if (data["command"].ToString() != "getLog") continue;
var response = GetStatus();
handler.Send(Encoding.UTF8.GetBytes(response));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.InnerException);
Console.WriteLine(ex.StackTrace);
}
}
問題はおそらく接続の反対側にあります。ほとんど処理されない例外です。 – HebeleHododo
これは、主にクライアントの接続が切断されたときに発生します。 –
[既存の接続がリモートホストによって強制的に閉じられました](http://stackoverflow.com/questions/2582036/an-existing-connection-was-forcibly-closed-by-the-remote-host) – HebeleHododo