Interface SocketConnector

  • All Superinterfaces:
    AutoCloseable

    public interface SocketConnector
    extends AutoCloseable
    The interface provides methods for creating socket connections.
    • Method Detail

      • getHost

        String getHost()
        Returns the hostname or IP address to connect.
        Returns:
        the hostname or IP address to connect
      • getPort

        int getPort()
        Returns the port number to connect.
        Returns:
        the port number to connect
      • setListener

        void setListener​(SocketConnector.Listener listener)
        Sets the listener for this socket connector.
        Parameters:
        listener - the listener to use for connection events
      • connect

        Socket connect()
                throws IOException
        Synchronous connection attempt.
        Returns:
        connected socket.
        Throws:
        IOException - if an error occurs during the binding/connection.
      • connectAsync

        void connectAsync()
        Initiates an asynchronous connection attempt.
      • connectAfterInterval

        void connectAfterInterval​(long interval,
                                  TimeUnit timeUnit)
        Initiates a connection attempt after a specified interval.
        Parameters:
        interval - the length of the interval
        timeUnit - the time unit for the interval