code: public static ApiConnection connect(SocketFactory fact, String host, int port, int timeOut) throws ApiConnectionException {
          ApiConnectionImpl con = new ApiConnectionImpl();
          con.open(host, port, fact, timeOut);
          return con;
      }
docs: Create a new API connection to the give device on the supplied port
  
  @param fact The socket factory used to construct the connection socket.
  @param host The host to which to connect.
  @param port The TCP port to use.
  @param timeOut The connection timeout
  @return The ApiConnection
  @throws me.legrange.mikrotik.ApiConnectionException Thrown if there is a
  problem connecting