套接字异常无法通过try catch处理

时间:2019-10-21 23:47:01

标签: c# .net sockets server console-application

我有此控制台应用程序Asynchronoumus服务器。 现在我的问题是几天或几天后,应用程序突然崩溃了。 但我尝试着抓住我拥有的每一种方法, 似乎该错误未由catch处理, 在查看应用程序事件查看器的日志后,我在崩溃的那一天发现了此错误。

null

我的代码

Application: CopyChimpServer.exe Framework Version: v4.0.30319 Description: 
The process was terminated due to an unhandled exception. Exception Info:
 System.Net.Sockets.SocketException at System.Net.Sockets.Socket.BeginReceive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags, 
System.AsyncCallback, System.Object) at CopyChimpServer.Program+<>c__DisplayClass2.<AcceptCallback>b__0()
 at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) 
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, 
System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, 
System.Threading.ContextCallback, System.Object) 
at System.Threading.ThreadHelper.ThreadStart()  

是否有避免此错误或捕获此错误的方法? 答案是否可以单独尝试BeginReceive?

0 个答案:

没有答案