我可以侦听端口(使用的HttpListener或其他。NET code)在Vista上,而不需要管理员priveleges?而不、或其他、端口、管理员

2023-09-02 01:44:05 作者:山谷幽兰

我使用的HttpListener以允许用户设置一个代理服务器的用户定义的端口上。当我开始的HttpListener,我如果申请是根据管理员权限在Vista中运行没有得到一个异常。

I'm using HttpListener to allow a user to set up a proxy on a user-defined port. When I start the HttpListener, I get an exception if the application isn't running under administrator privileges in Vista.

从我读过,这是预期的行为 - 管理员权限开始监听端口要求。但我敢肯定有办法解决这个,因为我运行大量的程序(如Skype)的监听端口,而不需要提升到管理员。

From what I've read, this is expected behavior - administrator privileges are required to start listening on a port. But I'm sure there are ways around this, as I run plenty of programs (like Skype) which listen on a port without requiring elevation to administrator.

有没有办法用的HttpListener做到这一点?如果不是这样,我可以在.NET code其它的API调用来设置端口?

Is there a way to do this with HttpListener? If not, can I make other API calls in .NET code to set up the port?

推荐答案

我从来没有用过一个的HttpListener,但是从你的描述听起来,而不是把你的应用程序融入了更多像你想一个普通的TCP端口上侦听,服务器URL命名空间(这是什么的HttpListener似乎做)。你应该能够使用普通插座功能(System.Net.Sockets.TcpListener)打开,听听一个TCP端口,无需管理员权限。我几乎可以肯定Skype不使用的HttpListener。

I've never used an HttpListener, but from your description it sounds more like you want to listen on a regular TCP port, instead of embedding your application into a server URL namespace (which is what HttpListener appears to do). You should be able to use regular socket functions (System.Net.Sockets.TcpListener) to open and listen on a TCP port without requiring administrator privileges. I'm almost certain Skype doesn't use an HttpListener.