java – Ping vs HTTP HEAD

I am writing a Java application that has the ability to check whether it is connected to the Internet by periodically trying to access the server My first idea was to Ping the server - but it turned out to be complex to implement in Java So I resend it to send the HTTP head request and check the HTTP response code I have two questions:

1) Is the HTTP head request "Ping" as reliable as ping? Ping will be my first natural selection to check whether something is available Maybe it's just that it's very simple to run on the command line

2) If I send an HTTP head request to a third-party website to check whether it is accessible, are there any standard frequencies that should be sent? For example, if I send it once a second, will it discourage or even make me block these services?

Solution

HTTP head is usually more reliable than Ping because ICMP connections are often blocked and HTTP is usually open Checking the connection once per second sounds quite a lot, but it actually depends on your use case. You try to "Ping" the third-party website

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>