Http Listener 不适用于端口 8080 或其他端口(仅适用于端口 80)

发布于 2024-09-12 07:26:16 字数 945 浏览 6 评论 0原文

我使用 HttpListener 类(.net 2.0)编写了一个简单的 WebServer,

它似乎无法在 80 以外的端口上工作。

当我嗅探到服务器的传输时,我可以看到端口 8080 上的 Syn 数据包到达服务器,但是没有 Syn/Ack 响应,尽管当我 sue netstat -ai 可以看到服务器正在侦听端口 8080(我验证了我的应用程序是侦听的)时,

HttpListener server = new HttpListener()
server.Prefixes.Add("http://192.168.4.133:8080/");
server.Start();
_log.Write("Waiting for a connection... ");
HttpListenerContext context = server.GetContext();
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
_log.Write("Got request for " + request.RawUrl);

上述代码没有收到任何上下文(卡在行 server.GetContext()) 如果我将前缀更改为“http://192.168.4.133/” 上面的代码完美运行。

当我在端口 80 上测试它时,我正在终止 IIS 服务,并确保我的应用程序是侦听相关端口的应用程序。

我在 XP 上运行这个,所以我不认为这是安全问题......但你永远不知道...... 我已经阅读过有关 httpcfg 工具的内容,但并没有真正理解它...

侦听端口 80 与侦听其他端口之间是否有本质上的区别? 8080 或者更好的另一个随机用户端口? 谢谢, 伊泰

I wrote a simple WebServer using HttpListener class (.net 2.0)

It seems that It doesn't work on port other then 80.

When i sniff the transport to my server i can see the Syn packets on Port 8080 arrive to the server, but there is no Syn/Ack response, although when i sue netstat -a i can see that the server is listening to port 8080 (i verified that my application is the one that listens)

HttpListener server = new HttpListener()
server.Prefixes.Add("http://192.168.4.133:8080/");
server.Start();
_log.Write("Waiting for a connection... ");
HttpListenerContext context = server.GetContext();
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
_log.Write("Got request for " + request.RawUrl);

the above code doesn't receive any Context (stuck at the line server.GetContext())
if i change the Prefix to "http://192.168.4.133/"
the above code works perfectly.

when i am testing it on Port 80, i am killing the IIS services, and making sure that my application is the one that listen to the relevant port.

i am running this on XP, so i don't think it is security issues....but you never know..
i have read about the httpcfg tool, but didnt really understood it...

is there something inherntly diffrent between listening on port 80 to listening on other ports? 8080 or even better another random user port?
Thanks,
Itay

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

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

发布评论

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

评论(2

梦里兽 2024-09-19 07:26:17

我建议检查你的防火墙,如果你没有找到任何东西 - 尝试在 8080 上运行另一台服务器并检查它是否正常工作(这样你就知道这是端口,而不是服务器)。

I'd suggest checking your firewall, and if you don't find anything -- try to run another server on 8080 and check if it's working (so you know that it's the port, not the server).

不如归去 2024-09-19 07:26:17

检查您的防火墙是否打开或关闭,如果打开,是否禁止该端口访问。
您可以暂时关闭它进行测试以确保安全。

旁注:无需寻找并终止 IIS 进程,只需停止 IIS Windows 服务(运行命令“services.msc”即可查看列表)

Check if you're firewall is on or off and if on, whether prohibiting this port access.
You can termorarily turn it of for the test just to make sure.

Side note: No need to be hunting down and killing IIS processes, simply stop the IIS windows service (run the command "services.msc" to see a list)

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