简体   繁体   中英

is it possible to make redirection if user's port 80 is busy?

I have a java application that runs on some server.

When user accesses this application, it needs to check if port 80 on user's machine is available. Based on the status, it will make some redirection.

My question... is it possible to check from java code if port 80 is busy on the user's machine?

There's no reliable method to check if a remote port is busy. Such behaviour will be a security breach. However, you can check if an HTTP resource is reachable just by requesting it. If unknown, server is supposed to return a 404 HTTP code.

However for local port, just try to open a server listening to this port using a ServerSocket

您无需检查用户计算机上的端口。该端口与URL结合使用。如果应用程序已在服务器上启动,则用户可能需要检查其是否能够访问服务器URL和端口。端口在计算机上打开(当然,除非服务器在您自己的本地计算机中)。您需要做的只是检查防火墙或网络问题,以便可以访问服务器。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM