4 Replies
      Latest reply on May 22, 2020 7:22 AM by meaton
      jimketcham Level 1 Level 1 (0 points)

        The TicTacToe example offers a Bonjour service (the listener) and discovers a service (the browser), but the listener does not give a 'query response' when the browser does discovery. This can be observed using WireShark. To demonstrate, start the listener end and offer a game without the 2nd copy (the browser end) running. Run the browser end, which does discovery (a query) when it starts. The listener does not give a 'query response', and does not get put in the browser's list of available games. 

        If both ends of the peer-to-peer game are running when the game is offered, then the game does appear in the browser's list of games.

        What setting is missing in the TicTacToe example to cause the 'query response'?

        • Re: TicTacToe example does not give a 'query response' to browser discovery
          jimketcham Level 1 Level 1 (0 points)

          In the MDNS probe, there are queries and answers. If you are queried and the response is in the answer section (in this case it is), you don't have to respond. That is why the TicTacToe server doesn't respond to the query.

          The client doesn't list the game, though, even though it has it in the answer section of the probe.

           

          The client adds and removes the game from the table view on discovery. 

           

          Tracing the table view delegate

          func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int){}

          the table view loads the game name, then unloads it immediately.

           

          So, now the question is why does the game name get removed?

            • Re: TicTacToe example does not give a 'query response' to browser discovery
              meaton Apple Staff Apple Staff (220 points)

              Do you mean, why does the game name get removed after a certain amount of inactivity, or just from the tableviews

              | So, now the question is why does the game name get removed?

               

              Matt Eaton

              DTS Engineering, CoreOS

              meaton3 at apple.com

                • Re: TicTacToe example does not give a 'query response' to browser discovery
                  jimketcham Level 1 Level 1 (0 points)

                  The issue is with NWBrowser and how it deals with cached DNS services.

                   

                  If the service (the game) isn't cached, then there is only a query in the DNS probe. The service gives a query response. NWBrowser calls browseResultsChangedHandler() once, with the service.

                   

                  If the service is cached, there is a query and answer in the DNS probe. The service doesn't give a query response because the service name is in the answer section of the probe. NWBrowser calls browseResultsChangedHandler() once, with the service from the cache, and then within 100 ms a second time, with no services. This is not always true in TicTacToe, but sometimes is. In a test program that I wrote, it is always true.

                   

                  If I accumulate the services rather than clearing 'results' every time (which TicTacToe does) then I have the service, and I can connect to it.

                   

                  The question is whether browseResultsChangedHandler() is calling with the complete list of services every time. From the documentation, it is 'updates', so I guess it is not the complete list, just additions. If that is true then TicTacToe shouldn't be clearing 'results' every time browseResultsChangedHandler() is called.

                    • Re: TicTacToe example does not give a 'query response' to browser discovery
                      meaton Apple Staff Apple Staff (220 points)

                      browseResultsChangedHandler is being called with updates and can be called multiple times.   Identical results recorded from the previous update will not result in an update call to browseResultsChangedHandler.  So what this means is browseResultsChangedHandler could be called for additions, removals, or changes etc..

                       

                      Cancelling the browser will stop updates from being populated on this callback.

                       

                       

                      Matt Eaton

                      DTS Engineering, CoreOS

                      meaton3 at apple.com