Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 669359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:08:34+00:00 2026-05-14T00:08:34+00:00

In Moritz Haarmann’s Blog I found an example of usage of Bonjour by Java

  • 0

In Moritz Haarmann’s Blog I found an example of usage of Bonjour by Java. Here is the code taken from there:

public class ServiceAnnouncer implements IServiceAnnouncer, RegisterListener {
    private DNSSDRegistration serviceRecord;
    private boolean registered;

    public boolean isRegistered(){
        return registered;
    }

    public void registerService()  {
        try {
            serviceRecord = DNSSD.register(0,0,null,"_killerapp._tcp", null,null,1234,null,this);
        } catch (DNSSDException e) {
            // error handling here
        }
    }

    public void unregisterService(){
        serviceRecord.stop();
                registered = false;
    }

    public void serviceRegistered(DNSSDRegistration registration, int flags,String serviceName, String regType, String domain){
        registered = true;
    }

    public void operationFailed(DNSSDService registration, int error){
        // do error handling here if you want to.
    }
}

I have a question about the “serviceRegistered” method. As far as I understand it is called during (or after) registration of the service (and it sets variable “registered” to be equal to “true”). But what is not clear to me is how exactly it is called. Because the service is registered by the method “registerService”. This method, in its turn, calls “DNSSD.register”. And, as far as I understand, the “DNSSD.register” will call the “serviceRegister” method of the “ServiceAnnouncer” class. But how “DNSSD.register” knows that it needs to call a method of the “ServiceAnnouncer” class? Can “DNSSD.register” know that it is called from a particular class (in this case “ServiceAnnouncer” class)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:08:34+00:00Added an answer on May 14, 2026 at 12:08 am

    The ServiceAnnouncer has passed itself as last argument of the DNSSD.register() method, which in turn is apparently expecting any instance of RegisterListener. This way the DNSSD can have a direct handle to the ServiceAnnouncer instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I took this script from here : import csv from itertools import izip f
This is my models.py from django.db import models class School(models.Model): school = models.CharField(max_length=300) def
I created a fixtures folder in the app directory and put data1.json in there.
Is this xpath a valid XPath expression? (It does what it should ). #!/usr/bin/env
In Spring MVC 2.5 with Jetty - probably with any servlet container -, I
Let's say I have this Hello.scala. object HelloWorld { def main(args: Array[String]) { println(Hello,
I want to get the value of users visiting my page for 10 days
I'm looking for a library or extension that enables ruby to work with IRIs
This view works when the query is in the database. def search(request): if 'q'
I am currently having issues with the 60 day access_token. I grab the fansite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.