0

我确信有更好的方式来描述我所面临的挑战,但希望这会足够清楚。

我有一台在局域网内的随机主机+端口上运行的服务器,我想知道该主机名和端口,或者至少是随机端口,以便我的(Web)客户端可以连接到正确的 URL。

这个特定的服务器恰好运行并响应 M-SEARCH (SSDP) 查询,但我认为您不能从网页/javascript 查询。

我不介意使用通用(云)服务器来帮助完成此过程。

编辑:想一想,我不知道我在想什么 UPNP 等,我的“客户端”只有一个浏览器和一个 URL 来提供,所以在他访问我的服务器之前我无法运行 JavaScript:端口。也许解决方案必须使用云上的某种众所周知的地址或主机上的知名端口。

4

1 回答 1

0

You can use the netstat command to find the open ports on a server (windows or linux)

example on linux to find a java app server:

netstat -anp | grep java 

Output - it was listening on port 8080:

tcp        0      0 10.121.235.200:8080    0.0.0.0:*               LISTEN      7051/java

And as a side note, you may find this useful, if you have an idea it should be a certain port, you can check if there's a process running that is listening to it by using lsof:

lsof -i :portNumber

Example:

lsof -i :80
于 2013-06-05T00:16:34.747 回答