“无法执行套接字上的操作,因为系统缺乏足够的缓冲区空间或因为队列已满”

发布于 2024-10-06 23:42:43 字数 420 浏览 3 评论 0原文

我用 C# 编写了一个 IP 多播应用程序。它编译得很好,但在运行时这一行:

sock.SetSocketOption(SocketOptionLevel.IP,
                     SocketOptionName.AddMembership,
                     new MulticastOption(IPAddress.Parse("224.100.0.1")));

抛出一个未处理的套接字异常:

由于系统缺少足够的缓冲区空间或队列已满,无法执行套接字上的操作

我在Google中搜索了错误,人们建议删除可能已启用的3GB开关(我的操作系统是Windows 7) 。我这样做了,但仍然遇到同样的错误。可能是什么问题?

I've written an IP multicasting application in C#. It compiles fine, but at runtime this line:

sock.SetSocketOption(SocketOptionLevel.IP,
                     SocketOptionName.AddMembership,
                     new MulticastOption(IPAddress.Parse("224.100.0.1")));

throws an unhandled socket exception:

An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

I searched for the error in Google and people have suggested to remove the 3GB switch (my OS is Windows 7) which may have been enabled. I did that, but still get the same error. What could be the issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

大海や 2024-10-13 23:42:43

可能是端口耗尽。
当应用程序在短时间内产生太多传出连接或未正确处理传出连接时,您就会耗尽端口。

Here 是相当冗长的解释和诊断问题的方法的链接

It could be port exhaustion.
When application(s) makes too many outgoing connections in short time frame or does not dispose outgoing connections properly - you run out of ports.

Here is the link to rather lengthy explanation and a way to diagnose the issue

零時差 2024-10-13 23:42:43

当您耗尽资源(套接字?)或内存时,似乎会发生这种情况。
在命令提示符下运行:
netstat -ab

我不确定套接字限制是什么。我自己目前正在解决这样的问题。

关于套接字限制的注意事项:
http://support.microsoft.com/kb/196271

This seems to happen when you run out of resources (sockets?) or memory.
At the command prompt run:
netstat -ab

I'm not sure off hand what the socket limit is. I'm currently fighting an issue like this myself.

Notes on socket limits:
http://support.microsoft.com/kb/196271

单调的奢华 2024-10-13 23:42:43

如果超出资源限制,您可能会遇到此错误消息。 System.Net.Sockets.Socket 实现 IDisposable。使用完插座后,您是否会处理掉它们?

将它们留给垃圾收集器是泄漏资源的好方法。

You can encounter this error message if resource limits are being exceeded. A System.Net.Sockets.Socket implements IDisposable. Are you disposing of your socket(s) once you're finished with them?

Leaving them around for the garbage collector is an excellent way to leak resources.

不美如何 2024-10-13 23:42:43

我有同样的错误,但仅限于 Windows 7。如果我在 Vista 上运行相同的多播应用程序,它就可以工作。它会弹出一个系统对话框来解锁应用程序的行为,但它会运行。这可能是win7中网络权限的改变。我仍在寻找解决方案。如果其他人找到了,请发布。

I have this same error, but only on Windows 7. If I run my same multicast app on Vista it works. It pops up a system dialog to unblock the behavior from the app, but it runs. This is probably a changed networking permissions thing in win7. I'm still looking for a solution. If someone else finds one, please post.

哭泣的笑容 2024-10-13 23:42:43

请参阅 - http://support.microsoft.com/kb/2553549https://support.microsoft.com/en-us/kb/929851(您确定有多少您想要的动态出站端口)。与第二篇文章一起,将 TcpTimedWaitDelay 设置为双字十进制值 30。这样,当套接字释放到系统时,清除速度会更快。
请参阅 - technet.microsoft.com/en-us/library/cc938217.aspx

see - http://support.microsoft.com/kb/2553549 and https://support.microsoft.com/en-us/kb/929851 (you determine how many dynamic outbout ports you want). Along with this second article, set the TcpTimedWaitDelay to dword decimal value of 30. So when sockets get released to the system, the clear faster.
See - technet.microsoft.com/en-us/library/cc938217.aspx

天气好吗我好吗 2024-10-13 23:42:43

在尝试连接到本地 MySQL 数据库时,我遇到了同样的问题(又名错误 10055)。我相信您需要增加操作系统允许的动态端口数量。

此处提到了对我有用的解决方案
我相信它也会对您有所帮助,因为您使用的是 Windows。
祝你好运!

I've had the same issue (a.k.a error 10055) when trying to connect to a local MySQL database. I believe you need to raise the number of dynamic ports that the operating system allows.

The solution that worked for me was mentioned here
I believe it may help you as well, since you are using Windows.
Best of luck!

凉城 2024-10-13 23:42:43

我在 Windows Server 2008 上遇到了同样的错误。就我而言,重新启动服务器(运行时间为 2 年)后问题得到解决。

I had the same error on Windows Server 2008. In my case, after restart the server (with 2 years uptime) problem solved.

落叶缤纷 2024-10-13 23:42:43

在 Windows Server 2012 R2 Datacenter x64 上联系瑞典名为 Loopia 的外部电子邮件提供商时出现此错误。

服务器已经快一年没有重启了。重新启动后一切正常。

输入图片此处描述

无法执行套接字上的操作,因为系统
缺乏足够的缓冲区空间或因为队列已满
194.9.94.72:993

描述:执行期间发生未处理的异常
当前的网络请求。请检查堆栈
跟踪以获取有关错误及其起源的更多信息
代码。

异常详细信息:System.Net.Sockets.SocketException:An
无法执行套接字上的操作,因为系统缺少
足够的缓冲区空间或因为队列已满 194.9.94.72:993

Got this error when contacting an external email provider in Sweden called Loopia on a Windows Server 2012 R2 Datacenter x64.

The server had not been rebooted for almost a year. After rebooting everything worked.

enter image description here

An operation on a socket could not be performed because the system
lacked sufficient buffer space or because a queue was full
194.9.94.72:993

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack
trace for more information about the error and where it originated in
the code.

Exception Details: 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 194.9.94.72:993

扛刀软妹 2024-10-13 23:42:43

我遇到了同样的问题,并注意到服务器上运行着许多旧的/被遗忘的自定义后台进程并消耗套接字。即使相同的进程也由不同的用户远程运行。

通过任务管理器进行简短的清理就完成了这项工作。或者如果可以的话,重新启动也是一种选择。

I had the same issue and noticed that there were a lot of old/forgotten custom background processes running on the server and consuming sockets. Even the same processes run remotely by different users.

A brief cleanup via Task Manager did the job. Or reboot could be an option if you can.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文