为什么会出现这种SocketException在我的C#的服务? [英] Why am I getting this SocketException in my C# service?

查看:744
本文介绍了为什么会出现这种SocketException在我的C#的服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种服务,负责读取和从服务器写入。
中的阅读和写作是在不同的线程完成的。



读者线程处于活动状态的所有时间,而写线程只激活发送消息和模具一旦消息。写入服务器和收到响应



该服务运行4天之后,我不断收到此错误,每当服务尝试从端口读取:




System.Net.Sockets.SocketException:无法执行套接字上的操作,因为
系统缺乏足够的缓冲空间,或因为队列已满



解决方案

当你建立了大量传出连接会发生这种情况很快,跑出来的本地端口。你可以阅读有关的临时端口范围这里



或者,你可以简单地用完插座。请确保您接近他们正在使用它们完成后。


I have a service that is responsible for reading and writing from a server. The reading and writing is done in different threads.

The reader thread is active all the time whereas write thread only activates to send message and dies once message is written to server and response is received.

The service runs for 4 days and after that I am getting this error continuously, whenever the service tries to read from the port:

System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

解决方案

This can happen when you establish a large number of outgoing connections very quickly and run out of local ports. You can read about the "ephemeral port range" here.

Or, you may simply be running out of sockets. Make sure you close them after you are done using them.

这篇关于为什么会出现这种SocketException在我的C#的服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆