本文介绍了当我不得不关闭套接字时管理SocketException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我对套接字不太满意,因此可以原谅无意义的问题...

我在Windows CE平台上开发了TCP服务器.我已经使用简单的Tcp侦听器创建了服务器,创建了不同的cleint,向其中读取数据,谢谢代码项目.

现在我面临一个问题,有时会出现SocketException.我的问题是在收到此类异常后我该怎么办?
我可以假设某个时候套接字肯定已经死了,有时我可以重新启动.

Hello all,

I am quite ne to socket, so forgive non-sense questions ...

I develop a tcp server on a Windows CE platform. I have created the server using simple Tcp Listenners, created the differents cleints, read write data to them, thank you code project.

Now i facing a problem, sometimes i get SocketException. My question is after getting a such exception what i have to do ?
I can suppose that sometime the socket is definitely dead, and sometimes, i can restart.

try
{
   this.MySocket.Send(...);
   this.MySocket.Receive(...);
} 
catch(SocketException ex)
{
   switch(ex.ErrorCode)
   {
       case ... :
          this.Retry();
          break;
       case ... : 
          this.MySocket.close();
          break;
    }
}




我在此处找到了所有错误代码,但是我怎么知道?

Romain TAILLANDIER




I have found all error code here, but how can i know ?

Romain TAILLANDIER

推荐答案


这篇关于当我不得不关闭套接字时管理SocketException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 06:27