我可以在不需要管理员权限的情况下侦听 Vista 上的端口(使用 HttpListener 或其他 .NET 代码)吗? [英] Can I listen on a port (using HttpListener or other .NET code) on Vista without requiring administrator priveleges?

查看:20
本文介绍了我可以在不需要管理员权限的情况下侦听 Vista 上的端口(使用 HttpListener 或其他 .NET 代码)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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 代码中调用其他 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.

这篇关于我可以在不需要管理员权限的情况下侦听 Vista 上的端口(使用 HttpListener 或其他 .NET 代码)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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