如何检查开放端口是TCP还是HTTP? [英] How do I check whether an open port is TCP or HTTP?

查看:4154
本文介绍了如何检查开放端口是TCP还是HTTP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,我有一台Windows服务器(Windows 7),但 netstat -an 命令只显示端口是TCP还是UDP。我认为这些是唯一的端口类型,但node.js似乎区分HTTP端口和TCP端口(链接页面底部的示例)。我目前在我的服务器上运行的程序中使用node.js,默认情况下会打开HTTP端口。这些显示为 netstat -an 下的TCP端口。

Specifically, I have a Windows server (Windows 7), but the netstat -an command only shows whether ports are TCP or UDP. I thought these were the only kinds of ports, but node.js seems to distinguish between HTTP ports and TCP ports (example at bottom of linked page). I'm currently using node.js in a program that will run on my server, and it opens HTTP ports by default. These appear as TCP ports under netstat -an.

是否有用于区分是否为开放端口的命令行技巧在这个服务器上是HTTP还是TCP?我向我的信息技术办公室请求我在这台服务器上需要的端口,他们需要知道这些端口是TCP,UDP等。

Is there a command line trick for distinguishing whether an open port on this server is HTTP or TCP? I make requests to my Information Technology office about ports that I need on this server, and they need to know whether these ports will be TCP, UDP, etc.

如有必要要使用远程客户端,我有一台Mac可以完成这项工作。

If necessary to use a remote client, I have a Mac that can do the job.

推荐答案

所有HTTP流量都通过TCP端口传输。我认为可能导致一些混淆的是第一个node.js示例使用 http 模块,第二个示例使用 net 模块。

All HTTP traffic is transmitted over TCP Ports. I think what may be causing some confusion is that the first node.js example uses the http module and the second example uses the net module.

http模块构建在net模块之上(处理基础HTTP的TCP层)。

The http module is built on top of the net module (which handles the TCP layer underlying HTTP).

请参阅: nodejs - net或http module

编辑:

只有一个进程可以绑定到端口。如果您在连接时遇到困难,请关闭可能使用相同端口的任何其他应用程序,例如Java Hello World服务器。运行 netstat -an 以确保在您的node.js TCP服务器(端口1337)中没有看到您尝试监听的端口。如果没有在端口上侦听,请启动node.js TCP服务器并再次运行 netstat -an 以确保它实际上正在侦听预期的端口。

Only one process can bind to a port. If you're having difficulties connecting, shut down any other applications that may be using the same port, such as your Java Hello World server. Run netstat -an to make sure you don't see the port listed that you're trying to listen on in you node.js TCP server (port 1337) in the example. If nothing is listening on the port, fire up your node.js TCP server and run netstat -an again to make sure it's actually listening on the intended port.

另一个建议 - 暂时关闭软件防火墙,然后使用本地服务器上的telnet客户端尝试使用命令 telnet连接到端口127.0.0.1 1337 (用您的端口替换1337)从命令提示符处。这将消除客户端(本例中为telnet)与服务器之间的任何网络设备,如防火墙。如果屏幕变为空白,则表示已连接。如果你收到消息无法打开与主机的连接,在端口上它仍然没有监听TCP端口。如果您可以从Telnet本地连接,但无法远程连接,则会阻止您的连接。

Another suggestion - temporarily turn off the software firewall then use the telnet client on the local server to attempt to connect to the port using the command telnet 127.0.0.1 1337 (replace 1337 with your port) from the command prompt. This will eliminate any network devices such as firewalls between the client (telnet in this case) and the server. If the screen goes blank, you've connected. If you get the message Could not open connection to the host, on port then it's still not listening on the TCP Port. If you can connect locally from Telnet but you cannot connect remotely then there is something blocking your connection.

这篇关于如何检查开放端口是TCP还是HTTP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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