Notes:
// %Z%%M%, %I%, %G%
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//This library is now licensed under the Apache License Version 2.0 Please
//see the file NOTICE.
Arthur van Hoff
avh@strangeberry.com
Rick Blair
rickblair@mac.com
** JmDNS
This is an implemenation of multi-cast DNS in Java. It currently
supports service discovery and service registration. It is fully
interoperable with Apple's Rendezvous.
** Requirements
jmdns has been tested using the JDK 1.3.1 and JDK 1.4.0
on the following platforms:
Windows 9x, XP, 2000
Linux RedHat 7.3-9.0, Mandrake
Mac OSX
** Running jmdns from the Command Line
GUI browser:
java -jar lib/jmdns.jar -browse
TTY browser for a particular service type:
java -jar lib/jmdns.jar -bs _http._tcp local.
Register a service:
java -jar lib/jmdns.jar -rs foobar _http._tcp local. 1234 path=index.html
List service types:
java -jar lib/jmdns.jar -bt
To print debugging output specify -d as the first argument.
** Sample Code for Service Registration
import javax.jmdns.*;
JmDNS jmdns = new JmDNS();
jmdns.registerService(
new ServiceInfo("_http._tcp.local.", "foo._http._tcp.local.", 1234, 0, 0, "path=index.html")
);
** Sample code for Serivice Discovery
import javax.jmdns.*;
static class SampleListener implements ServiceListener
{
public void addService(JmDNS jmdns, String type, String name)
{
System.out.println("ADD: " + jmdns.getServiceInfo(type, name));
}
public void removeService(JmDNS jmdns, String type, String name)
{
System.out.println("REMOVE: " + name);
}
public void resolveService(JmDNS jmdns, String type, String name, ServiceInfo info)
{
System.out.println("RESOLVED: " + info);
}
}
JmDNS jmdns = new JmDNS();
jmdns.addServiceListener("_http._tcp.local.", new SampleListener());
** Changes since October 2003
- Renamed package com.strangeberry.rendezvous to javax.jmdns
- fixed unicast queries
- fixed property handling
- use the hostname instead of the service name is address resolution
- Added Apache License.
Changes:
CHANGELOG 16 July 2005 Rick Blair
1. Added Apache License Version 2.0
2. Added shutdown fix as identifed by Scott Lewis
3. Added copyright notice.
4. General code cleanup.
CHANGELOG 30 November 2004 rawcoder
1. IPv6 support
- RFE 890432: IPv6 support implemented
2. Logging
- Logging is done using the Java Logger API now
3. Bug fixes
- JmDNS reannounces services after their TTL has timed out.
4. Plattform dependency
- Due to the changes done for IPv6 support and the logging,
JmDNS requires now a JVM supporting a J2SE 1.4 API.
CHANGELOG 6 June 2004 rawcoder
1. General API Changes
- RFE 868432: Changed listener API to comply with the commonly used
EventListener/EventObject idiom
- RFE 868433: Added a list method to class JmDNS which can be used to
retrieve a list of available services without having to
implement a ServiceListener.
- RFE 892855: All API's use now unqualified service instance names
2. General implementation changes
- JmDNS now runs through the Rendezvous Conformance Test, when the options
"-M hn" are used.
- Threads are now handled differently. ServiceListeners and
ServiceTypeListeners can not assume anymore that they are invoked from
the AWT event dispatcher thread.
- States are now handled explicitly using class DNSState.
3. DNSCache
- Removed the hash table code and use now a java.util.Hashtable.
- This reduces the overall size of the class.
4. DNSConstants
- Added several new time interval constants.
5. DNSEntry
- Now overrides method hashCode() to return a value, that is consistent with
method equals().
6. DNSIncoming
- Added a warning to constant EMPTY. Using this constant is dangerous, because a Vector
is mutable. Thus it can not be used as a constant this way.
- Made many instance variables and methods private.
- Added more output to method print(), to help me debug JmDNS.
- Optimized StringBuffer handling in method toString().
- Added methods isTruncated() and append().
- DNSIncoming must adjust variables numAnswers, numAuthorities, numAdditionals when skipping records.
7. DNSOutgoing
- Made as many instance variables private as I could.
- Added assertions (using if-Statements) to all add...() methods to prevent construction of
illegal data structures.
8. DNSRecord
- Made as many instance variables private as I could.
- Moved code from class JmDNS into class DNSRecord. The new operations are named: handleQuery()
handleResponse() and addAnswer(). This is to get rid of the big switch-statements that were
in method handleQuery() and handleResponse() of class JmDNS.
This does somehow make the relationship between these two classes a little bit more complex though.
9. JmDNS
- Added comments to some of the instance variables.
- Added an instance variable named 'state' to track the state of the host name published by JmDNS, and of
JmDNS itself.
- Replaced instance variable 'Vector browsers' by a hash map named 'serviceListeners'.
- Got rid of the query cache. All caching is done now by a single cache.
- Added instance variables for counting probe throttles.
- Added an instance variable named 'hostNameCount' to create a new host name, when a conflict was detected.
- Added a java.util.Timer. All outgoing messages and maintenance of the cache is now coordinated using the
timer. This greatly reduces the number of concurrent threads.
- Added an instance variable named 'ioLock'. This lock is used to coordinate the incoming listener thread
with the timer tasks.
- Added a static variable named 'random'. It is used to generate random delays for responses.
- All outgoing tasks such as probing, announcing, responding and canceling are now handled by instances of
TimerTask.
- Added an instance variable named 'task', to keep track of timer tasks associated with the host name.
- Transferred code from JmDNS to DNSRecord to get rid of some ugly switch statements.
10. ServiceInfo
- Added an instance variable named 'state' to track the state of the service.
This is used only, if the service is published by JmDNS.
- Added an instance variable named 'task', to keep track of timer tasks associated with the service info.
11. Sample code
- Added a "samples" package to JmDNS. This package contains sample
programs for JmDNS.
12. JavaDoc
- Added a "package.html" file for each package. This file holds package
documentation used by JavaDoc.
13. Build
- Added a "samples" task to build.xml.
- The "javadoc" task puts now a version number into the header of
each generated page.
CHANGELOG 21 APRIL 2004 RickBlair
1. JmDNS
-Fixed broken additionals in the Query Function.
-Added additionals to the SVC query.
CHANGELOG 28-29 MAR 2004 jeffs
1. JmDNS
- Added probing thread to handle address record probing and conflicts
- Fixed wait times to be in line with the draft mDNS spec.
- Added query cache so can check if another machine is also
probing for our address.
- Added support for slowing down the request rate during
probing as per the draft mDNS spec.
- Added conflict checks.
- General code clean up.
- changed visibility of static debug variable to public
so apps can check it and decide to do their own logging and so on
- changed visbility of all non-static variables to private
- added package protected method getCache()
- broke up handleQuery() into:
private DNSOutgoing typeA()
private DNSOutgoing typePTR()
private DNSOutgoing findService()
- reduced handleQuery() synchronized block
to just cover Socket.send() call
[need to figure out what else needs synchronization]
2. ServiceInfo
- changed all calls to JmDNS cache variable
to use JmDNS getCache() accessor instead
- replaced javadoc comment
<code>_http._tcp.local.</code>
with
<code>_http._tcp.local.</code>
so the javadoc tool would quit whining
3. DNSConstants
- Added constants for wait times and probe times.
- changed to be a final class
- changed all references to it's fields in all other classes
to read DNSConstants.whatever
Know Problems.
-- The additional section is broken in handleQuery. This will be fixed in the next go round.
-- Service probing is still not to spec. No conflict resolution.
-- Still can blow address space on very busy networks.
Copyright © 2009 Geeknet, Inc. All rights reserved. Terms of Use