NetFunctions (SelekTOR Java Documentation)
Date: 2017-04-14

lib

## Class NetFunctions

- java.lang.Object
- - lib.NetFunctions

-     public class NetFunctions
      extends java.lang.Object

  Author:
    Alistair Neil,

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `NetFunctions.HttpPage` Store an http formatted web page

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `CONNECTION_FAILED`
    `static int` | `EVENT_NETLATENCY`
    `static int` | `EVENT_URLFAILED`
    `static int` | `EVENT_URLOK`
    `static int` | `FILE_FAILED`
    `static int` | `FILE_LOCAL_ISNEWER`
    `static int` | `FILE_RETRIEVED`
    `static long` | `LATENCY_FAIL`
    `static long` | `LATENCY_UNKNOWN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NetFunctions()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getLatency(java.lang.String surl, java.net.Proxy proxy, int timeout)` Get latency non threaded version
    `java.lang.String` | `getURLContentAsString(java.lang.String sourceurl, java.net.Socket s)` Check web for updates and return version string if an update is available
    `boolean` | `isIPAddress(java.lang.String ipaddress)` Make sure ipaddress is valid number
    `java.io.InputStream` | `openStreamToURL(java.lang.String surl, java.net.Socket s)` Open an inputstream to the given url on the given socket
    `int` | `saveURLContentToFile(java.lang.String destfile, java.lang.String sourceurl, java.net.Socket socket, boolean force)` Save the contents of a URL to a file
    `void` | `setProgressBar(javax.swing.JProgressBar jpb)`
    `void` | `setSocketTimeout(int timeout)` Set default socket timeout

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CONNECTION_FAILED

          public static final int CONNECTION_FAILED

      See Also:
        Constant Field Values

    - #### FILE_LOCAL_ISNEWER

          public static final int FILE_LOCAL_ISNEWER

      See Also:
        Constant Field Values

    - #### FILE_RETRIEVED

          public static final int FILE_RETRIEVED

      See Also:
        Constant Field Values

    - #### FILE_FAILED

          public static final int FILE_FAILED

      See Also:
        Constant Field Values

    - #### EVENT_URLOK

          public static final int EVENT_URLOK

      See Also:
        Constant Field Values

    - #### EVENT_URLFAILED

          public static final int EVENT_URLFAILED

      See Also:
        Constant Field Values

    - #### EVENT_NETLATENCY

          public static final int EVENT_NETLATENCY

      See Also:
        Constant Field Values

    - #### LATENCY_FAIL

          public static final long LATENCY_FAIL

      See Also:
        Constant Field Values

    - #### LATENCY_UNKNOWN

          public static final long LATENCY_UNKNOWN

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NetFunctions

          public NetFunctions()

  - ### Method Detail

    - #### setSocketTimeout

          public void setSocketTimeout(int timeout)

      Set default socket timeout
      Parameters:
        `timeout` -

    - #### setProgressBar

          public void setProgressBar(javax.swing.JProgressBar jpb)

    - #### saveURLContentToFile

          public int saveURLContentToFile(java.lang.String destfile,
                                          java.lang.String sourceurl,
                                          java.net.Socket socket,
                                          boolean force)

      Save the contents of a URL to a file
      Parameters:
        `destfile` - File destination path
        `sourceurl` - URL
        `socket` -
        `force` - Forces update regardless of age
      Returns:
        int File retieval status code

    - #### isIPAddress

          public boolean isIPAddress(java.lang.String ipaddress)

      Make sure ipaddress is valid number
      Parameters:
        `ipaddress` -
      Returns:
        true if a valid ip address

    - #### getLatency

          public long getLatency(java.lang.String surl,
                                 java.net.Proxy proxy,
                                 int timeout)

      Get latency non threaded version
      Parameters:
        `surl` - Testing url
        `proxy` - Specify a proxy, null == no proxy
        `timeout` - Specify a timeout before declaring failure
      Returns:
        long latency in milliseconds

    - #### getURLContentAsString

          public java.lang.String getURLContentAsString(java.lang.String sourceurl,
                                                        java.net.Socket s)

      Check web for updates and return version string if an update is available
      Parameters:
        `sourceurl` - URL to check
        `s` - Socket
      Returns:
        String new version number

    - #### openStreamToURL

          public java.io.InputStream openStreamToURL(java.lang.String surl,
                                                     java.net.Socket s)

      Open an inputstream to the given url on the given socket
      Parameters:
        `surl` -
        `s` -
      Returns:
        inputstream