1

My project uses the tethering components from Delphi 10.4.

In some cases the components fail to connect, often where they connected in the past on the same network. The components give no errors. The Windows firewall shows that the project app is included in its list of app exceptions.

How can my project test that the tethering component can read and write data from the internet?

Here is the code on the consuming side:

procedure TChessOpeningsWizardMainForm.ChessEngineTetheringManagerEndManagersDiscovery(
  const Sender: TObject; const ARemoteManagers: TTetheringManagerInfoList);
var
  i: Integer;
  theTotalPaired: Integer;
begin
  // ShowMessage('There were ' + IntToStr(ARemoteManagers.Count) + ' chess engine remote managers found.');

  theTotalPaired := 0;

  for i:=0 to ARemoteManagers.Count-1 do
    if ARemoteManagers[i].ManagerText = 'COWEngineManager'
      then
        begin
          {$IFDEF DEBUG}
          CodeSite.Send('COW ChessEngineTetheringManagerEndManagersDiscovery: Calling PairManager[' + IntToStr(i) + ']');
          {$ENDIF}

          ChessEngineTetheringManager.PairManager(ARemoteManagers[I]);   // FIXEDIN build 38
          Inc(theTotalPaired);
        end;

  fEngineTetheringIsConnected := (theTotalPaired > 0);  // FIXEDIN build 40

  ArrangeVisualComponents;

  // ShowMessage('Out of ' + IntToStr(ARemoteManagers.Count) + ' remote managers found, ' + IntToStr(theTotalPaired) + ' were paired.');
  // CodeSite.Send('Out of ' + IntToStr(ARemoteManagers.Count) + ' remote managers found, ' + IntToStr(theTotalPaired) + ' were paired.');
  {$IFDEF DEBUG}
  CodeSite.Send('COW Out of ' + IntToStr(ARemoteManagers.Count) + ' remote COWEngineManager(s) found, ' + IntToStr(theTotalPaired) + ' were paired.');
  {$ENDIF}

  if (theTotalPaired = 0) and
     (fProgramMode = kModeNormal)
    then SetMode(kModeShowChessEngineServerNotFound);
end;



procedure TChessOpeningsWizardMainForm.ChessEngineTetheringManagerEndProfilesDiscovery(
  const Sender: TObject; const ARemoteProfiles: TTetheringProfileInfoList);
var
  i: Integer;
begin
  for i:=0 to ChessEngineTetheringManager.RemoteProfiles.Count-1 do
    ChessEngineTetheringAppProfile.Connect(ChessEngineTetheringManager.RemoteProfiles[i]);

  if (ChessEngineTetheringManager.RemoteProfiles.Count > 0)
    then
      begin
        {$IFDEF DEBUG}
        CodeSite.Send('ChessEngineTetheringManagerEndProfilesDiscovery called with ' + ChessEngineTetheringManager.RemoteProfiles.Count.ToString + ' remote profiles.');
        {$ENDIF}

        fEngineTetheringIsConnected := True;

        ArrangeVisualComponents;

        UpdateEngineWithCurrentPosition;
      end
    else
      begin
        {$IFDEF DEBUG}
        CodeSite.Send('ChessEngineTetheringManagerEndProfilesDiscovery called but with no remote profiles.');
        {$ENDIF}
      end;
end;
Mike at Bookup
  • 1,211
  • 14
  • 32
  • 1
    Keep in mind that "network" and "internet (access)" are two very different things. – AmigoJack Feb 27 '21 at 13:09
  • 1
    Could you show the code you use at both side of the connection. Show this in a minimal reproducible example. Did you visit: http://docwiki.embarcadero.com/RADStudio/Sydney/en/Connecting_to_Remote_Applications_Using_App_Tethering – fpiette Feb 27 '21 at 14:12
  • 1
    I have this demo, which is shows one way to determine if a connection to the internet is available: https://github.com/DelphiWorlds/Kastri/tree/master/Demos/Connectivity. Note that it relies on other files in the Kastri library, including these: https://github.com/DelphiWorlds/Kastri/tree/master/Features/Connectivity – Dave Nottage Feb 27 '21 at 21:18
  • 1
    @DaveNottage Thanks for the demo. It crashes with invalid pointer operation in FCurrent.Free; when run on Windows with Delphi 10.4.2. It looks like it has what I need though. – Mike at Bookup Mar 01 '21 at 19:39
  • @MikeatBookup Thanks.. I'll look into it – Dave Nottage Mar 01 '21 at 19:41

0 Answers0