Class SocketTimeout


  • public final class SocketTimeout
    extends Object
    Helper Class to iniciate timeouts in connections e.g. Databases, SMTP Servers and so on.
    • Method Detail

      • isUrlAvailable

        public static boolean isUrlAvailable​(String url)
        Check if a URL e. g. www.google.com is available. It is a simple test if a connection to the internet is possible.
        Parameters:
        url - as String
        Returns:
        true on success
      • timeout

        public static boolean timeout​(int milliseconds,
                                      String uri,
                                      int port)
        Initiate a timeout after the given time in milliseconds are passed. 1 Second = 1000 Milliseconds. Useful values to interrupt connection are between 3000 and 5000.
        The method return a success true when a connection can be established.
        Parameters:
        milliseconds - as long
        uri - as String
        port - as int
        Returns:
        true on success