mono/linux套接字被拒绝? [英] mono/linux socket denied?

查看:81
本文介绍了mono/linux套接字被拒绝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 alchemy websockets ,并弄清楚了可以在Windows上正常工作的地方.我用mono在linux(ubuntu)上构建了炼金术并运行了我的服务器.它得到一个套接字错误.端口> 1k(确切地说是端口8005)

I am using alchemy websockets and figured out enough to get something working on windows. I built alchemy on linux (ubuntu) with mono and ran my server. It gets a socket error. The port is >1k (port 8005 to be exact)

Unhandled Exception: System.Net.Sockets.SocketException: Access denied
  at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.TcpListener.Start (Int32 backlog) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.TcpListener.Start () [0x00000] in <filename unknown>:0 
  at Alchemy.TcpServer.Listen (System.Object state) [0x00000] in <filename unknown>:0 

从文件名看来,我好像忘了使用调试信息进行构建或未安装符号,但是我确实成功地在mono上进行了构建.它使用.NET 4.0 mono 2.10

From the filename it looks like i forgot to build with debug information or didnt install symbols but i did successfully build on mono. Its using .NET 4.0 mono 2.10

为什么我无法通过套接字访问?

Why am i getting access denied on sockets?

推荐答案

要检查的几件事

netstat -a | grep 8005查看是否有其他端口正在使用端口8005

netstat -a | grep 8005 See if something else is using port 8005

以su身份运行,看看是否存在权限问题

Run as su to see if it's a permission problem

sudo mono YourProgram.exe

我对所使用的库没有很好的了解,但是如果它使用ICMP或Raw Sockets,则必须以root身份运行.

I didn't take a good look at the library you are using, but if it uses ICMP or Raw Sockets it has to run as root.

要查看的另一件事是查看您使用的DNS分辨率是否匹配.沙盒运行时通常只对此抱怨,但是我已经看到了奇怪的事情发生,并且您没有给我们提供太多信息.

Another thing to look at is to see if the DNS resolution you are using matches. Sandboxed runtimes normally only complain about this, but I've seen stranger things happen and you haven't given us much information to go on.

如果这是一个根本问题,而不是另一个程序正在使用端口8005,则您可能可以在单二进制文件上使用setcap,因此不必以root身份运行它.

If it is a root problem and not that another program is using port 8005 you might be able to get away with using setcap on the mono binary so you don't have to run it as root.

以root身份运行此命令: setcap cap_net_raw=iep /path/to/mono

Run this as root: setcap cap_net_raw=iep /path/to/mono

这篇关于mono/linux套接字被拒绝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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