Package com.castlabs.android.network

# Class SocketConnectivityCheck

java.lang.Object
com.castlabs.android.network.SocketConnectivityCheck

All Implemented Interfaces:
  `ConnectivityCheck`

Direct Known Subclasses:
  `GoogleDNSConnectivityCheck`

public class SocketConnectivityCheck extends Object implements ConnectivityCheck
Connectivity check that uses a socket connection to a specified host and port. This is useful for checking network connectivity by attempting to connect to a specific host.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SocketConnectivityCheck(Context context, String lookupHost, int port, int timeoutMs)`
  Check the connectivity by establishing a connection to lookupHost:port with connection timeoutMs

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `isConnected()`
  Returns true if an internet connection is available

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

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

- ## Constructor Details

  - ### SocketConnectivityCheck

    public SocketConnectivityCheck(@NonNull Context context, @NonNull String lookupHost, int port, int timeoutMs)
    Check the connectivity by establishing a connection to lookupHost:port with connection timeoutMs
    Parameters:
      `context` - The context
      `lookupHost` - Hostname or IP address. IP address is preferable as it will not raise any potential timing/unpredicted DNS resolution issues
      `port` - The port
      `timeoutMs` - The connection timeout in ms

- ## Method Details

  - ### isConnected

    public boolean isConnected()
    Description copied from interface: `ConnectivityCheck`
    Returns true if an internet connection is available
    Specified by:
      `isConnected` in interface `ConnectivityCheck`
    Returns:
      True if an internet connection is available